The personal finance app for everyone (by everyone)
Ruby
Remove dead account identifier columns (Questrade/Redbark/Monobank) (#3827)
GFR8fa8300cd847
diff --git a/app/models/monobank_account.rb b/app/models/monobank_account.rbindex 6d98b16272..bf6e618301 100644--- a/app/models/monobank_account.rb+++ b/app/models/monobank_account.rb@@ -27,10 +27,6 @@ class MonobankAccount < ApplicationRecordif encryption_ready?encrypts :raw_payloadencrypts :raw_transactions_payload- # Not deterministic: neither column is ever looked up by value, and an IBAN plus a- # partial card number are exactly the fields worth keeping opaque at rest.- encrypts :masked_pan- encrypts :ibanendbelongs_to :monobank_item@@ -100,8 +96,6 @@ class MonobankAccount < ApplicationRecordaccount_id: snapshot[:id],account_kind: kind,account_type: account_type_for(snapshot, kind: kind),- masked_pan: Array(snapshot[:maskedPan]).first.presence,- iban: snapshot[:iban].presence,provider: "monobank",institution_metadata: {name: INSTITUTION_NAME,diff --git a/app/models/redbark_account.rb b/app/models/redbark_account.rbindex 8a54ae4ffb..5b77b2065a 100644--- a/app/models/redbark_account.rb+++ b/app/models/redbark_account.rb@@ -66,7 +66,6 @@ class RedbarkAccount < ApplicationRecordredbark_account_id: data[:id]&.to_s,connection_id: data[:connectionId]&.to_s,name: display_name,- account_number: data[:accountNumber],currency: extract_currency(data, fallback: parse_currency(currency) || "AUD"),account_status: connection[:status],account_type: data[:type],diff --git a/db/migrate/20260929120000_remove_dead_account_identifier_columns.rb b/db/migrate/20260929120000_remove_dead_account_identifier_columns.rbnew file mode 100644index 0000000000..f35eb6105e--- /dev/null+++ b/db/migrate/20260929120000_remove_dead_account_identifier_columns.rb@@ -0,0 +1,17 @@+# frozen_string_literal: true++class RemoveDeadAccountIdentifierColumns < ActiveRecord::Migration[8.1]+ def up+ remove_column :questrade_accounts, :account_number+ remove_column :redbark_accounts, :account_number+ remove_column :monobank_accounts, :iban+ remove_column :monobank_accounts, :masked_pan+ end++ def down+ add_column :questrade_accounts, :account_number, :string+ add_column :redbark_accounts, :account_number, :string+ add_column :monobank_accounts, :iban, :string+ add_column :monobank_accounts, :masked_pan, :string+ end+enddiff --git a/db/schema.rb b/db/schema.rbindex 39c7e3696b..08961cce9f 100644--- a/db/schema.rb+++ b/db/schema.rb@@ -10,7 +10,7 @@## It's strongly recommended that you check this file into your version control system.-ActiveRecord::Schema[8.1].define(version: 2026_09_28_180000) do+ActiveRecord::Schema[8.1].define(version: 2026_09_29_120000) do# These are extensions that must be enabled in order to support this databaseenable_extension "pg_catalog.plpgsql"enable_extension "pgcrypto"@@ -918,7 +918,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_09_28_180000) dot.index ["account_id"], name: "index_financekit_account_lineages_on_account_id"t.index ["family_id", "account_id"], name: "financekit_lineage_canonical_account", unique: true, where: "(account_id IS NOT NULL)"t.index ["family_id"], name: "index_financekit_account_lineages_on_family_id"- t.check_constraint "account_origin IS NULL OR (account_origin::text = ANY (ARRAY['created'::character varying, 'linked'::character varying]::text[]))", name: "financekit_lineage_account_origin"+ t.check_constraint "account_origin IS NULL OR (account_origin::text = ANY (ARRAY['created'::character varying::text, 'linked'::character varying::text]))", name: "financekit_lineage_account_origin"endcreate_table "financekit_accounts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|@@ -1729,10 +1729,8 @@ ActiveRecord::Schema[8.1].define(version: 2026_09_28_180000) dot.string "currency", null: falset.decimal "current_balance", precision: 19, scale: 4t.datetime "history_synced_from"- t.string "iban"t.boolean "ignored", default: false, null: falset.jsonb "institution_metadata"- t.string "masked_pan"t.uuid "monobank_item_id", null: falset.string "name", null: falset.string "provider"@@ -1980,7 +1978,6 @@ ActiveRecord::Schema[8.1].define(version: 2026_09_28_180000) doendcreate_table "questrade_accounts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|- t.string "account_number"t.string "account_status"t.string "account_type"t.boolean "activities_fetch_pending", default: false@@ -2178,7 +2175,6 @@ ActiveRecord::Schema[8.1].define(version: 2026_09_28_180000) doendcreate_table "redbark_accounts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|- t.string "account_number"t.string "account_status"t.string "account_type"t.string "connection_id"diff --git a/test/encryption_verification_test.rb b/test/encryption_verification_test.rbindex 0b4f6059e7..b5871c8387 100644--- a/test/encryption_verification_test.rb+++ b/test/encryption_verification_test.rb@@ -337,25 +337,18 @@ class EncryptionVerificationTest < ActiveSupport::TestCaseassert_column_not_plaintext(MonobankItem, item.id, :raw_payload, "test")end- test "monobank account payloads and identifiers are encrypted" do+ test "monobank account payloads are encrypted" doskip "No monobank accounts in fixtures" unless MonobankAccount.any?account = MonobankAccount.firstaccount.update!(raw_payload: { account_test: "value" },- raw_transactions_payload: [ { id: "tx_probe" } ],- masked_pan: "537541******9999",- iban: "UA-TEST-IBAN-ENCRYPTION-PROBE"+ raw_transactions_payload: [ { id: "tx_probe" } ])account.reloadassert_equal({ "account_test" => "value" }, account.raw_payload)- assert_equal "537541******9999", account.masked_pan- assert_equal "UA-TEST-IBAN-ENCRYPTION-PROBE", account.iban- # A partial card number and an IBAN are exactly the fields worth proving opaque.- assert_column_not_plaintext(MonobankAccount, account.id, :masked_pan, "537541******9999")- assert_column_not_plaintext(MonobankAccount, account.id, :iban, "UA-TEST-IBAN-ENCRYPTION-PROBE")assert_column_not_plaintext(MonobankAccount, account.id, :raw_payload, "account_test")assert_column_not_plaintext(MonobankAccount, account.id, :raw_transactions_payload, "tx_probe")enddiff --git a/test/fixtures/monobank_accounts.yml b/test/fixtures/monobank_accounts.ymlindex d681df8572..214fe8a08b 100644--- a/test/fixtures/monobank_accounts.yml+++ b/test/fixtures/monobank_accounts.yml@@ -6,5 +6,3 @@ black_card:current_balance: 1500.00account_kind: "card"account_type: "black"- masked_pan: "537541******1234"- iban: "UA-TEST-IBAN-FIXTURE"diff --git a/test/models/monobank_account_test.rb b/test/models/monobank_account_test.rbindex 5951118ef5..21f2fa5410 100644--- a/test/models/monobank_account_test.rb+++ b/test/models/monobank_account_test.rb@@ -35,8 +35,7 @@ class MonobankAccountTest < ActiveSupport::TestCase"balance" => 150_00,"creditLimit" => 100_00,"currencyCode" => 980,- "maskedPan" => [ "537541******1234" ],- "iban" => "UA-TEST-IBAN-SNAPSHOT"+ "maskedPan" => [ "537541******1234" ]})@@ -45,7 +44,7 @@ class MonobankAccountTest < ActiveSupport::TestCaseassert_equal "UAH", monobank_account.currencyassert_equal "black", monobank_account.account_typeassert_equal "card", monobank_account.account_kind- assert_equal "537541******1234", monobank_account.masked_pan+ assert_equal "Black card ·1234", monobank_account.nameassert_equal "Depository", monobank_account.suggested_account_typeassert_equal "checking", monobank_account.suggested_subtypeend