Files
sure/db/migrate/20251111084519_remove_orphaned_lunchflow_accounts.rb
soky srm fad241c416 Fixes & Improvements (#316)
* Some improvements

- Fix issue with lunch flow accounts that were imported
- Remove the period comparison section from reports

* Add cleanup migration

* FIX for dynamic config

* Fix linter

* FIX settings setter

Reuse the base class’ atomic setter to leverage its locking and cache invalidation.

* Make upsert atomic

* Remove migration file

Signed-off-by: soky srm <sokysrm@gmail.com>

* Delete db/migrate/20251111094448_migrate_dynamic_fields_to_individual_entries.rb

Signed-off-by: soky srm <sokysrm@gmail.com>

* Fix cache reset

* Revert "Remove migration file"

This reverts commit 1f2a21ef58.

* Revert "Delete db/migrate/20251111094448_migrate_dynamic_fields_to_individual_entries.rb"

This reverts commit 29dcaaafb2.

* Fix Plaid initialiser

---------

Signed-off-by: soky srm <sokysrm@gmail.com>
2025-11-11 19:51:07 +01:00

29 lines
1.2 KiB
Ruby

class RemoveOrphanedLunchflowAccounts < ActiveRecord::Migration[7.2]
def up
# Find all LunchflowAccount records that don't have an associated account_provider
# These are "orphaned" accounts that were created during sync but never actually
# imported/linked by the user due to old behavior that saved all accounts
orphaned_accounts = LunchflowAccount.left_outer_joins(:account_provider)
.where(account_providers: { id: nil })
orphaned_count = orphaned_accounts.count
if orphaned_count > 0
Rails.logger.info "Removing #{orphaned_count} orphaned LunchflowAccount records (not linked via account_provider)"
# Delete orphaned accounts
orphaned_accounts.destroy_all
Rails.logger.info "Successfully removed #{orphaned_count} orphaned LunchflowAccount records"
else
Rails.logger.info "No orphaned LunchflowAccount records found to remove"
end
end
def down
# Cannot restore orphaned accounts that were deleted
# These were unused accounts from old behavior that shouldn't have been created
Rails.logger.info "Cannot restore orphaned LunchflowAccount records (data migration is irreversible)"
end
end