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

28 lines
599 B
Ruby
Raw Normal View History

class MigrateProfileToStatisticProfile < ActiveRecord::Migration
def up
User.all.each do |u|
p = u.profile
puts "WARNING: User #{u.id} has no profile" and next unless p
StatisticProfile.create!(
user: u,
group: u.group,
gender: p.gender,
birthday: p.birthday
)
end
end
def down
StatisticProfile.all.each do |sp|
p = sp.user.profile
puts "WARNING: User #{sp.user_id} has no profile" and next unless p
p.update_attributes(
gender: sp.gender,
birthday: sp.birthday
)
end
end
end