1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/db/migrate/20190604064929_migrate_reservation_to_statistic_profile.rb

20 lines
445 B
Ruby

class MigrateReservationToStatisticProfile < ActiveRecord::Migration
def up
Reservation.all.each do |r|
user = User.find(r.user_id)
r.update_column(
'statistic_profile_id', user.statistic_profile.id
)
end
end
def down
Reservation.all.each do |r|
statistic_profile = User.find(r.statistic_profile_id)
r.update_column(
'user_id', statistic_profile.user_id
)
end
end
end