mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
For the schedule versioning in the admin interface (having multiple possible shcedules) we need to change some models and associations. It has also been create a rake:move_events_attributes task to migrate the data. User Interface addapted to make use of the introduced associations and models
24 lines
882 B
Ruby
24 lines
882 B
Ruby
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.id
|
|
program.save
|
|
program.events.each do |event|
|
|
unless event.start_time.nil? && event.room_id.nil?
|
|
# we can not use .room as this relation has been removed
|
|
EventSchedule.create(event: event,
|
|
schedule: schedule,
|
|
start_time: event.start_time,
|
|
room_id: event.room_id)
|
|
event.start_time = nil
|
|
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
|