parent
f14bf75b30
commit
00e4170593
@ -0,0 +1,11 @@
|
||||
class MigrateCourseSchoolId < ActiveRecord::Migration
|
||||
def up
|
||||
courses = Course.includes(teacher: :user_extensions).where("courses.school_id != user_extensions.school_id or courses.school_id is null")
|
||||
courses.each do |course|
|
||||
course.update_column('school_id', course.teacher.try(:user_extensions).try(:school_id))
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in new issue