Rename raw_investments_payload to raw_holdings_payload for Plaid accounts (#760)

* refactor: rename `raw_investments_payload` to `raw_holdings_payload`

- Update references and models to use consistent naming.
- Adjust migrations, tests, and encryption setup accordingly.

* fix: improve safety when accessing raw_holdings_payload keys

- Use `dig` with safe navigation to prevent potential nil errors.
- Add support for decryption from the old column name `raw_investments_payload`.
- Adjust related methods and calculations for consistency.

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
This commit is contained in:
LPW
2026-01-24 05:16:26 -05:00
committed by GitHub
parent 8c9764f1ad
commit d98711d4ea
15 changed files with 35 additions and 29 deletions

View File

@@ -0,0 +1,5 @@
class RenameRawInvestmentsPayloadToRawHoldingsPayload < ActiveRecord::Migration[7.2]
def change
rename_column :plaid_accounts, :raw_investments_payload, :raw_holdings_payload
end
end

4
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2026_01_23_000000) do
ActiveRecord::Schema[7.2].define(version: 2026_01_23_214127) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
@@ -943,7 +943,7 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_23_000000) do
t.datetime "updated_at", null: false
t.jsonb "raw_payload", default: {}
t.jsonb "raw_transactions_payload", default: {}
t.jsonb "raw_investments_payload", default: {}
t.jsonb "raw_holdings_payload", default: {}
t.jsonb "raw_liabilities_payload", default: {}
t.index ["plaid_id"], name: "index_plaid_accounts_on_plaid_id", unique: true
t.index ["plaid_item_id"], name: "index_plaid_accounts_on_plaid_item_id"