课程表的数据迁移

This commit is contained in:
cxt 2016-02-20 18:16:07 +08:00
parent 7305b20ab0
commit 3369183fb7
2 changed files with 21 additions and 3 deletions

View File

@ -0,0 +1,19 @@
class UpdateCourseTerm < ActiveRecord::Migration
def up
count = Course.all.count / 30 + 2
transaction do
for i in 1 ... count do i
Course.page(i).per(30).each do |course|
if course.end_time.nil? && course.end_term.nil?
course.end_time = course.time
course.end_term = course.term
course.save
end
end
end
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. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160202034530) do ActiveRecord::Schema.define(:version => 20160220100507) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -1219,7 +1219,6 @@ ActiveRecord::Schema.define(:version => 20160202034530) do
create_table "org_members", :force => true do |t| create_table "org_members", :force => true do |t|
t.integer "user_id" t.integer "user_id"
t.integer "organization_id" t.integer "organization_id"
t.string "role"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
@ -1374,7 +1373,7 @@ ActiveRecord::Schema.define(:version => 20160202034530) do
t.integer "changeset_num", :default => 0 t.integer "changeset_num", :default => 0
t.integer "board_message_num", :default => 0 t.integer "board_message_num", :default => 0
t.integer "board_num", :default => 0 t.integer "board_num", :default => 0
t.integer "act_num", :default => 0 t.integer "act_num", :default => 0
t.integer "attach_num", :default => 0 t.integer "attach_num", :default => 0
t.datetime "commit_time" t.datetime "commit_time"
end end