1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-21 06:09:38 +02:00
Maybe/db/migrate/20240302145715_add_classification_to_accounts.rb
Zach Gollwitzer facd74f733
Net worth calculation (#508)
* Add classification generated column to account

* Add basic net worth calculation

* Add net worth tests

* Fix lint errors
2024-03-04 08:31:22 -05:00

18 lines
440 B
Ruby

class AddClassificationToAccounts < ActiveRecord::Migration[7.2]
def change
change_table :accounts do |t|
t.virtual(
:classification,
type: :string,
stored: true,
as: <<-SQL
CASE
WHEN accountable_type IN ('Account::Loan', 'Account::Credit', 'Account::OtherLiability')
THEN 'liability'
ELSE 'asset'
END
SQL
)
end
end
end