2019-06-04 13:33:00 +02:00
|
|
|
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,
|
2019-06-06 13:58:49 +02:00
|
|
|
role: u.roles.first,
|
2019-06-04 13:33:00 +02:00
|
|
|
gender: p.gender,
|
2019-06-06 16:54:09 +02:00
|
|
|
birthday: p.birthday,
|
|
|
|
created_at: u.created_at
|
2019-06-04 13:33:00 +02:00
|
|
|
)
|
|
|
|
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
|