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