Skip to content
Snippets Groups Projects
Unverified Commit f8abf8da authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

handle school-less programs in cohorts migration

parent 6dbf58cb
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,11 @@ class AddSchoolToCohorts < ActiveRecord::Migration[6.1]
def change
add_reference :education_cohorts, :school, foreign_key: {to_table: :education_schools}, type: :uuid
Education::Cohort.all.each do |cohort|
cohort.school_id = cohort.program.schools.first.id
cohort.save
if cohort.program.schools.any?
cohort.update(school_id: cohort.program.schools.first.id)
else
cohort.destroy
end
end
change_column_null :education_cohorts, :school_id, false
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment