From 044370b95814f06a297efbbfe0be1d6710b6e8c9 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 19 Jun 2015 14:21:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=9B=E5=BB=BA=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20150619060110_homework_common_time.rb | 19 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20150619060110_homework_common_time.rb diff --git a/db/migrate/20150619060110_homework_common_time.rb b/db/migrate/20150619060110_homework_common_time.rb new file mode 100644 index 000000000..c574ad93c --- /dev/null +++ b/db/migrate/20150619060110_homework_common_time.rb @@ -0,0 +1,19 @@ +class HomeworkCommonTime < ActiveRecord::Migration + def up + count = StudentWork.all.count / 100 + 1 + transaction do + for i in 1 ... count do i + StudentWork.page(i).per(100).each do |homework| + old_homework = HomeworkAttach.where(:user_id => homework.user_id, :name => homework.name, :description => homework.description).first + if old_homework + homework.update_column('created_at', old_homework.created_at) + end + end + end + puts i.to_s + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 68f00c1cd..420432355 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150604153000) do +ActiveRecord::Schema.define(:version => 20150619060110) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false