class ChangeEcCourseSupports < ActiveRecord::Migration[5.2]
  def change
    add_column :ec_course_supports, :ec_graduation_subitem_id, :integer, index: true

    execute <<-SQL
      UPDATE ec_course_supports ecs SET ec_graduation_subitem_id = (
        SELECT ec_graduation_subitem_id FROM ec_graduation_subitem_courses egsc WHERE egsc.ec_course_support_id = ecs.id
      )
    SQL
  end
end
