Only replace selected schedule if there is none

We have introduced this task a long time ago without any
release. In the meantime there might be people who have deployed,
hence have selected schedules already. Happened to openSUSE.
This commit is contained in:
Henne Vogelsang 2019-03-05 20:01:47 +01:00
parent 1e5558660f
commit f9442bd07d
No known key found for this signature in database
GPG key ID: 9D6164C2955FADE0

View file

@ -6,8 +6,8 @@ namespace :data do
task move_events_attributes: :environment do
Program.all.each do |program|
schedule = Schedule.create(program: program)
program.selected_schedule = schedule
program.save
program.selected_schedule = schedule unless program.selected_schedule
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