1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-26 00:29:40 +02:00
Maybe/db/migrate/20240206031739_replace_money_field.rb
Adrien Poly d3151be9ae
fix migration and add smoke test for migrations (#438)
* adds a smoke test in the CI for the migration

* add back money rails gem

* really remove money-rails

* update the migration to remove add_monetize
2024-02-11 12:34:18 -06:00

14 lines
420 B
Ruby

class ReplaceMoneyField < ActiveRecord::Migration[7.2]
def change
add_column :accounts, :balance_cents
change_column :accounts, :balance_cents, :integer, limit: 8
Account.reset_column_information
Account.find_each do |account|
account.update_columns(balance_cents: Money.from_amount(account.balance_in_database, account.currency).cents)
end
remove_column :accounts, :balance
end
end