mirror of
https://github.com/we-promise/sure.git
synced 2026-08-12 11:10:20 +00:00
* Display multi-currency holdings correctly * Implement IBKR provider * Fix: Use historical exchange rate for historical prices * Add brokerage exchange rate for trades * Sync historical balances from IBKR * Add logos in activity history * Fix privacy mode blur in account view * Improve IBKR XML Flex report parser errors
42 lines
1.4 KiB
Ruby
42 lines
1.4 KiB
Ruby
class CreateIbkrItemsAndAccounts < ActiveRecord::Migration[7.2]
|
|
def change
|
|
create_table :ibkr_items, id: :uuid do |t|
|
|
t.references :family, null: false, foreign_key: true, type: :uuid
|
|
t.string :name
|
|
t.string :status, default: "good", null: false
|
|
t.boolean :scheduled_for_deletion, default: false, null: false
|
|
t.boolean :pending_account_setup, default: false, null: false
|
|
t.jsonb :raw_payload
|
|
t.string :query_id
|
|
t.string :token
|
|
|
|
t.timestamps
|
|
end
|
|
|
|
add_index :ibkr_items, :status
|
|
|
|
create_table :ibkr_accounts, id: :uuid do |t|
|
|
t.references :ibkr_item, null: false, foreign_key: true, type: :uuid
|
|
t.string :name
|
|
t.string :ibkr_account_id
|
|
t.string :currency
|
|
t.decimal :current_balance, precision: 19, scale: 4
|
|
t.decimal :cash_balance, precision: 19, scale: 4
|
|
t.jsonb :institution_metadata
|
|
t.jsonb :raw_holdings_payload, default: [], null: false
|
|
t.jsonb :raw_activities_payload, default: {}, null: false
|
|
t.jsonb :raw_cash_report_payload, default: [], null: false
|
|
t.date :report_date
|
|
t.datetime :last_holdings_sync
|
|
t.datetime :last_activities_sync
|
|
|
|
t.timestamps
|
|
end
|
|
|
|
add_index :ibkr_accounts, [ :ibkr_item_id, :ibkr_account_id ],
|
|
unique: true,
|
|
where: "(ibkr_account_id IS NOT NULL)",
|
|
name: "index_ibkr_accounts_on_item_and_ibkr_account_id"
|
|
end
|
|
end
|