1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-22 22:59:39 +02:00
Maybe/db/migrate/20240215201527_create_valuations.rb

17 lines
588 B
Ruby
Raw Normal View History

class CreateValuations < ActiveRecord::Migration[7.2]
def change
create_table :valuations, id: :uuid do |t|
t.string :type, null: false
t.references :account, null: false, type: :uuid, foreign_key: { on_delete: :cascade }
t.date :date, null: false
t.decimal :value, precision: 19, scale: 4, null: false
t.string :currency, default: "USD", null: false
t.timestamps
end
# Since all dates are daily (no concept of time of day), limit account to 1 valuation per day
add_index :valuations, [ :account_id, :date ], unique: true
end
end