whisper-money/database/migrations
Víctor Falcón 4408f719b4
fix(banking): update external_account_id on reconnect and store IBAN (#220)
## Problem

Enable Banking issues **new account UIDs** (`external_account_id`) with
every new session. On reconnect, `AuthorizationController::callback()`
was correctly updating `session_id` on the `banking_connections` table
but **never refreshing `external_account_id` on child accounts**.

When the background `SyncBankingConnectionJob` ran after a reconnect, it
called `GET /accounts/{old-uid}/transactions` using stale UIDs from the
expired session, causing Enable Banking to return `401 EXPIRED_SESSION`
— surfaced to users as _"Authentication failed. Your credentials may
have expired or been revoked."_

## Changes

- **`AuthorizationController`** — added `refreshAccountIds()` private
method, called in the reconnect branch after `session_id` is updated and
before the sync job is dispatched. Matches existing accounts by **IBAN
first**, falls back to **positional order** (`created_at ASC`) for
legacy accounts without a stored IBAN.
- **`AuthorizationController`** — `createAccountsFromSession()` and
`createAccountsFromPending()` now persist the `iban` field on account
creation so future reconnects can use IBAN matching.
- **`Account` model** — `iban` added to `$fillable`.
- **Migration** — adds nullable `iban` column to `accounts` table.

## Tests

4 new feature tests in `AuthorizationControllerTest`:

- `reconnect callback updates external_account_id when enable banking
issues new account uids`
- `reconnect callback matches accounts by iban before falling back to
position`
- `reconnect callback uses positional fallback for accounts without
stored iban`
- `callback stores iban when creating accounts for the first time`

## Deploy notes

Run the migration after deploying:

```
php artisan migrate --force
```
2026-03-12 10:28:23 +00:00
..
0001_01_01_000000_create_users_table.php Set up a fresh Laravel app 2025-11-07 12:01:36 +00:00
0001_01_01_000001_create_cache_table.php Set up a fresh Laravel app 2025-11-07 12:01:36 +00:00
0001_01_01_000002_create_jobs_table.php Set up a fresh Laravel app 2025-11-07 12:01:36 +00:00
2025_08_26_100418_add_two_factor_columns_to_users_table.php Set up a fresh Laravel app 2025-11-07 12:01:36 +00:00
2025_11_07_135255_add_encryption_salt_to_users_table.php E2E Encryption 2025-11-07 14:21:25 +00:00
2025_11_07_135256_create_encrypted_messages_table.php E2E Encryption 2025-11-07 14:21:25 +00:00
2025_11_07_150038_create_banks_table.php feat: Add financial models and seeders 2025-11-07 15:45:28 +00:00
2025_11_07_150122_create_accounts_table.php feat: Add financial models and seeders 2025-11-07 15:45:28 +00:00
2025_11_07_150613_create_categories_table.php feat: Add financial models and seeders 2025-11-07 15:45:28 +00:00
2025_11_07_150659_create_transactions_table.php feat: Add financial models and seeders 2025-11-07 15:45:28 +00:00
2025_11_07_184056_modify_banks_table_add_user_id_and_simplify_name.php Banks accounts 2025-11-07 19:19:29 +00:00
2025_11_07_185018_change_banks_logo_to_text.php Banks accounts 2025-11-07 19:19:29 +00:00
2025_11_08_140230_change_transactions_id_to_uuid.php Update transaction amount to bigint 2025-11-15 20:53:47 +01:00
2025_11_08_141344_make_category_id_nullable_in_transactions_table.php Sync transactions 2025-11-08 14:17:16 +00:00
2025_11_08_144530_add_soft_deletes_to_transactions_table.php Transactions page 2025-11-08 23:38:35 +00:00
2025_11_10_110100_create_automation_rules_table.php Automation rules 2025-11-10 12:08:58 +00:00
2025_11_15_172640_create_account_balances_table.php Add account balances 2025-11-15 20:27:18 +01:00
2025_11_15_175636_change_transactions_amount_to_bigint.php Update transaction amount to bigint 2025-11-15 20:53:47 +01:00
2025_11_15_195739_convert_all_ids_to_uuid.php fix: migration history 2025-12-30 07:22:19 +01:00
2025_11_18_184409_create_user_leads_table.php Merge pull request #1 from whisper-money/landing-page 2025-11-24 12:11:35 +01:00
2025_11_28_104227_add_source_to_transactions_table.php Save transaction source (manually_created, or imported) 2025-11-28 12:36:48 +01:00
2025_11_29_170353_add_type_to_categories_table.php Add category type field support (#2) 2025-12-01 20:19:47 +01:00
2025_11_29_170955_fix_account_balances_unique_constraint.php fix: migration history 2025-12-30 07:22:19 +01:00
2025_12_01_101443_add_unique_constraint_to_categories_table.php Add unique constraint to categories table and update factory data 2025-12-01 11:19:16 +01:00
2025_12_06_112515_create_customer_columns.php Subscriptions (#15) 2025-12-06 19:09:56 +01:00
2025_12_06_112516_create_subscriptions_table.php Subscriptions (#15) 2025-12-06 19:09:56 +01:00
2025_12_06_112517_create_subscription_items_table.php Subscriptions (#15) 2025-12-06 19:09:56 +01:00
2025_12_06_112518_add_meter_id_to_subscription_items_table.php Subscriptions (#15) 2025-12-06 19:09:56 +01:00
2025_12_06_112519_add_meter_event_name_to_subscription_items_table.php Subscriptions (#15) 2025-12-06 19:09:56 +01:00
2025_12_10_142006_add_onboarded_at_to_users_table.php User Onboarding Flow (#23) 2025-12-12 13:06:08 +01:00
2025_12_12_092647_create_labels_table.php feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
2025_12_12_092650_create_label_transaction_table.php feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
2025_12_12_092651_create_automation_rule_labels_table.php feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
2025_12_12_141955_update_labels_unique_constraint_include_deleted_at.php feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
2025_12_16_151952_create_user_mail_logs_table.php feat: Implement drip email campaign system (#35) 2025-12-30 07:22:18 +01:00
2025_12_19_092437_create_budgets_table.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
2025_12_19_092443_create_budget_periods_table.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
2025_12_19_092446_create_budget_transactions_table.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
2025_12_20_154221_create_features_table.php Add Cashflow Analytics Feature (#49) 2026-01-05 13:06:50 +01:00
2025_12_29_063338_add_currency_code_to_users_table.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
2026_01_08_192757_add_email_identifier_to_user_mail_logs.php feat: Send custom emails to users (#52) 2026-01-09 09:33:19 +01:00
2026_01_08_204223_update_user_mail_logs_unique_constraint.php feat: Send custom emails to users (#52) 2026-01-09 09:33:19 +01:00
2026_01_21_151353_add_indexes_for_budget_transaction_assignment.php feat: Load transactions history on budget created (#72) 2026-01-22 11:10:15 +01:00
2026_01_22_071325_add_processing_historical_to_budget_periods.php feat: Load transactions history on budget created (#72) 2026-01-22 11:10:15 +01:00
2026_01_22_143232_add_locale_to_users_table.php feat: Spanish localization (#74) 2026-02-08 11:58:08 +01:00
2026_02_08_103953_create_user_settings_table.php Add chart color scheme setting (#101) 2026-02-28 12:58:21 +01:00
2026_02_09_110624_add_encrypted_to_accounts_table.php Remove encryption from bank account names (#104) 2026-02-09 14:15:26 +01:00
2026_02_09_131403_make_description_iv_nullable_on_transactions.php feat: Plaintext transactions behind feature flag (#105) 2026-02-10 14:31:24 +01:00
2026_02_09_144915_create_banking_connections_table.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
2026_02_09_144959_add_banking_connection_fields_to_accounts_table.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
2026_02_09_144959_add_external_transaction_id_to_transactions_table.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
2026_02_10_085759_add_aspsp_logo_to_banking_connections_table.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
2026_02_10_095639_add_raw_data_to_transactions_table.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
2026_02_11_113115_add_pending_accounts_data_to_banking_connections_table.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
2026_02_11_113119_add_linked_at_to_accounts_table.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
2026_02_13_083716_add_original_description_to_transactions_table.php feat: Add per-bank description formatter for bank-synced transactions (#120) 2026-02-13 09:54:58 +01:00
2026_02_18_084241_add_api_token_to_banking_connections_table.php feat: Add Indexa Capital integration (#130) 2026-02-18 10:42:13 +01:00
2026_02_18_110556_add_api_secret_to_banking_connections_table.php feat: Add Binance integration (#131) 2026-02-18 15:23:46 +01:00
2026_02_20_074846_create_exchange_rates_table.php feat: Add multi-currency conversion for net worth charts (#138) 2026-02-20 10:45:23 +01:00
2026_02_22_180317_add_invested_amount_to_account_balances_table.php feat: investment benefits — show gains/losses on investment accounts (#140) 2026-02-23 13:59:10 +01:00
2026_02_24_193117_fix_budget_transaction_refund_amounts.php fix(budgets): handle refunds correctly in budget spending calculations (#152) 2026-02-24 21:12:36 +01:00
2026_03_03_114620_add_paywall_seen_at_to_users_table.php feat(subscription): allow free plan for open banking users without connected banks (#188) 2026-03-03 22:28:50 +00:00
2026_03_04_085843_add_waitlist_columns_to_user_leads_table.php fix(migration): make add_waitlist_columns migration idempotent (#200) 2026-03-04 12:06:38 +00:00
2026_03_04_094926_add_locale_to_user_leads_table.php feat(waitlist): waiting list with referral system (#199) 2026-03-04 12:36:47 +01:00
2026_03_12_095411_add_iban_to_accounts_table.php fix(banking): update external_account_id on reconnect and store IBAN (#220) 2026-03-12 10:28:23 +00:00