1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-23 12:52:20 +01:00
fab-manager/db/migrate/20160704095606_create_wallets.rb

25 lines
600 B
Ruby
Raw Normal View History

# frozen_string_literal:true
2023-02-17 11:44:04 +01:00
# Create Wallets, which are a way to virtually save money for users
class CreateWallets < ActiveRecord::Migration[4.2]
2016-07-18 18:16:54 +02:00
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
2023-02-17 11:44:04 +01:00
execute <<-SQL.squish
INSERT INTO wallets (user_id, amount, created_at, updated_at)
2023-02-17 11:44:04 +01:00
SELECT users.id, 0, '#{Time.current.iso8601}', '#{Time.current.iso8601}'
FROM users
SQL
2016-07-18 18:16:54 +02:00
end
def down
drop_table :wallets
end
end