From cfcfc9c58072158ed11b1316821c022fef75b733 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 29 Mar 2019 15:59:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0329070441_migrate_homework_common_end_times.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 db/migrate/20190329070441_migrate_homework_common_end_times.rb 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