osem-fcy/lib/tasks/several_schedules.rake

23 lines
760 B
Ruby
Raw Normal View History

namespace :data do
desc 'Move the start_time and room attributes from Event to EventSchedule'
task move_events_attributes: :environment do
Program.all.each do |program|
schedule = Schedule.create(program: program)
program.selected_schedule = schedule
program.save
program.events.each do |event|
2017-03-04 01:27:51 +05:30
unless event.room_id.nil?
# we can not use .room as this relation has been removed
EventSchedule.create(event: event,
schedule: schedule,
room_id: event.room_id)
event.room_id = nil
event.save
end
end
end
puts 'The start_time and room attributes has been moved from Event to EventSchedule'
end
end