Files
sure/db/migrate/20260115100000_add_entry_protection_flags.rb
LPW c391ba2b23 Harden SimpleFIN sync: protect user data, fix stuck syncs, optimize API calls (#671)
* Implement entry protection flags for sync overwrites

- Added `user_modified` and `import_locked` flags to `entries` table to prevent provider sync from overwriting user-edited and imported data.
- Introduced backfill migration to mark existing entries based on conditions.
- Enhanced sync and processing logic to respect protection flags, track skipped entries, and log detailed stats.
- Updated UI to display skipped/protected entries and reasons in sync summaries.

* Localize error details summary text and adjust `sync_account_later` method placement

* Restored schema.rb

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-16 12:34:06 +01:00

18 lines
997 B
Ruby

class AddEntryProtectionFlags < ActiveRecord::Migration[7.2]
def change
# user_modified: Set when user manually edits any field on an entry.
# Prevents provider sync from overwriting user's intentional changes.
# Does NOT prevent user from editing - only protects from automated overwrites.
add_column :entries, :user_modified, :boolean, default: false, null: false
# import_locked: Set when entry is created via CSV/manual import.
# Prevents provider sync from overwriting imported data.
# Does NOT prevent user from editing - only protects from automated overwrites.
add_column :entries, :import_locked, :boolean, default: false, null: false
# Partial indexes for efficient queries when filtering protected entries
add_index :entries, :user_modified, where: "user_modified = true", name: "index_entries_on_user_modified_true"
add_index :entries, :import_locked, where: "import_locked = true", name: "index_entries_on_import_locked_true"
end
end