作品创建时间迁移

This commit is contained in:
sw 2015-06-19 14:21:36 +08:00
parent b6ff494b56
commit 044370b958
2 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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