mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Integrate money-rails gem (#268)
* Integrate money-rails gem * Fix Lint issues * Basic test for monetize feature * Merge main branch * Changes to monetize balance field --------- Co-authored-by: Zach Gollwitzer <zach.gollwitzer@gmail.com>
This commit is contained in:
parent
323a8ccf50
commit
1182ab39bd
12 changed files with 176 additions and 14 deletions
14
db/migrate/20240206031739_replace_money_field.rb
Normal file
14
db/migrate/20240206031739_replace_money_field.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class ReplaceMoneyField < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
add_monetize :accounts, :balance
|
||||
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, account.currency).cents)
|
||||
end
|
||||
|
||||
remove_column :accounts, :balance
|
||||
end
|
||||
end
|
5
db/schema.rb
generated
5
db/schema.rb
generated
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2024_02_03_050018) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2024_02_06_031739) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
|
@ -59,12 +59,13 @@ ActiveRecord::Schema[7.2].define(version: 2024_02_03_050018) do
|
|||
t.string "subtype"
|
||||
t.uuid "family_id", null: false
|
||||
t.string "name"
|
||||
t.bigint "balance", default: 0
|
||||
t.string "currency", default: "USD"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "accountable_type"
|
||||
t.uuid "accountable_id"
|
||||
t.bigint "balance_cents", default: 0, null: false
|
||||
t.string "balance_currency", default: "USD", null: false
|
||||
t.index ["accountable_type"], name: "index_accounts_on_accountable_type"
|
||||
t.index ["family_id"], name: "index_accounts_on_family_id"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue