1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-06 05:55:21 +02:00

Checkpoint

This commit is contained in:
Zach Gollwitzer 2025-07-08 10:25:16 -04:00
parent 15f8d827b5
commit b7acef1e7a
9 changed files with 56 additions and 23 deletions

View file

@ -3,21 +3,18 @@ class AddValuationKindFieldForAnchors < ActiveRecord::Migration[7.2]
add_column :valuations, :kind, :string, default: "recon"
add_column :valuations, :balance, :decimal, precision: 19, scale: 4
add_column :valuations, :cash_balance, :decimal, precision: 19, scale: 4
add_column :valuations, :currency, :string
# Copy `amount` from Entry, set both `balance` and `cash_balance` to the same value on all Valuation records, and `currency` from Entry to Valuation
execute <<-SQL
UPDATE valuations
SET
balance = entries.amount,
cash_balance = entries.amount,
currency = entries.currency
cash_balance = entries.amount
FROM entries
WHERE entries.entryable_type = 'Valuation' AND entries.entryable_id = valuations.id
SQL
change_column_null :valuations, :kind, false
change_column_null :valuations, :currency, false
change_column_null :valuations, :balance, false
change_column_null :valuations, :cash_balance, false
end
@ -26,6 +23,5 @@ class AddValuationKindFieldForAnchors < ActiveRecord::Migration[7.2]
remove_column :valuations, :kind
remove_column :valuations, :balance
remove_column :valuations, :cash_balance
remove_column :valuations, :currency
end
end

1
db/schema.rb generated
View file

@ -783,7 +783,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_07_07_130134) do
t.string "kind", default: "recon", null: false
t.decimal "balance", precision: 19, scale: 4, null: false
t.decimal "cash_balance", precision: 19, scale: 4, null: false
t.string "currency", null: false
end
create_table "vehicles", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|