1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/db/migrate/20190523123916_migrate_wallet_to_invoicing_profile.rb

32 lines
795 B
Ruby

class MigrateWalletToInvoicingProfile < ActiveRecord::Migration
def up
Wallet.all.each do |w|
user = User.find(w.user_id)
w.update_attributes(
invoicing_profile_id: user.invoicing_profile.id
)
end
WalletTransaction.all.each do |wt|
user = User.find(wt.user_id)
wt.update_attributes(
invoicing_profile_id: user.invoicing_profile.id
)
end
end
def down
Wallet.all.each do |w|
invoicing_profile = User.find(w.invoicing_profile_id)
w.update_attributes(
user_id: invoicing_profile.user_id
)
end
WalletTransaction.all.each do |wt|
invoicing_profile = User.find(wt.invoicing_profile_id)
wt.update_attributes(
user_id: invoicing_profile.user_id
)
end
end
end