mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-11 22:24:21 +01:00
32 lines
795 B
Ruby
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
|