mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-26 20:54:21 +01:00
24 lines
526 B
Ruby
24 lines
526 B
Ruby
# frozen_string_literal:true
|
|
|
|
class CreateWallets < ActiveRecord::Migration[4.2]
|
|
def up
|
|
create_table :wallets do |t|
|
|
t.belongs_to :user, index: true, foreign_key: true
|
|
t.integer :amount, default: 0
|
|
|
|
t.timestamps null: false
|
|
end
|
|
|
|
# create all wallets
|
|
execute <<-SQL
|
|
INSERT INTO wallets (user, amount, created_at, updated_at)
|
|
SELECT users.id, 0, #{DateTime.current.iso8601}, #{DateTime.current.iso8601}
|
|
FROM users
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
drop_table :wallets
|
|
end
|
|
end
|