diff --git a/db/migrate/20190329070441_migrate_homework_common_end_times.rb b/db/migrate/20190329070441_migrate_homework_common_end_times.rb new file mode 100644 index 00000000..0fa7b6cb --- /dev/null +++ b/db/migrate/20190329070441_migrate_homework_common_end_times.rb @@ -0,0 +1,14 @@ +class MigrateHomeworkCommonEndTimes < ActiveRecord::Migration + def up + homework_commons = HomeworkCommon.where("id < 21549") + homework_commons.find_each do |homework| + sql = "update homework_commons set end_time = (select max(end_time) from + homework_seconds where id = #{homework.id}) where id = #{homework.id}" + + ActiveRecord::Base.connection.execute(sql) + end + end + + def down + end +end