add fiat balance

This commit is contained in:
João Geonizeli
2021-08-11 22:53:59 -03:00
parent 1847a276f7
commit fe474dfb08
21 changed files with 596 additions and 116 deletions

View File

@@ -0,0 +1,11 @@
# frozen_string_literal: true
class CreateFiatBalances < ActiveRecord::Migration[6.1]
def change
create_table(:fiat_balances) do |t|
t.references(:user, null: false, foreign_key: true)
t.monetize(:amount)
t.timestamps
end
end
end

12
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_08_11_121726) do
ActiveRecord::Schema.define(version: 2021_08_12_011039) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -71,6 +71,15 @@ ActiveRecord::Schema.define(version: 2021_08_11_121726) do
t.datetime "updated_at", precision: 6, null: false
end
create_table "fiat_balances", force: :cascade do |t|
t.bigint "user_id", null: false
t.integer "amount_cents", default: 0, null: false
t.string "amount_currency", default: "BRL", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["user_id"], name: "index_fiat_balances_on_user_id"
end
create_table "user_documents", force: :cascade do |t|
t.string "status", null: false
t.bigint "user_id", null: false
@@ -97,5 +106,6 @@ ActiveRecord::Schema.define(version: 2021_08_11_121726) do
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "balances", "currencies"
add_foreign_key "balances", "users"
add_foreign_key "fiat_balances", "users"
add_foreign_key "user_documents", "users"
end

View File

@@ -214,3 +214,5 @@ currencies.each do |currency|
amount: random_floating_number
)
end
FiatBalance.create(user_id: user.id)