From 3369183fb75d92d653c8ef2c9a349593595bf69d Mon Sep 17 00:00:00 2001 From: cxt Date: Sat, 20 Feb 2016 18:16:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=A1=A8=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20160220100507_update_course_term.rb | 19 +++++++++++++++++++ db/schema.rb | 5 ++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20160220100507_update_course_term.rb diff --git a/db/migrate/20160220100507_update_course_term.rb b/db/migrate/20160220100507_update_course_term.rb new file mode 100644 index 000000000..afd849779 --- /dev/null +++ b/db/migrate/20160220100507_update_course_term.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 1c9866602..c22b79790 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 => 20160202034530) do +ActiveRecord::Schema.define(:version => 20160220100507) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1219,7 +1219,6 @@ ActiveRecord::Schema.define(:version => 20160202034530) do create_table "org_members", :force => true do |t| t.integer "user_id" t.integer "organization_id" - t.string "role" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end @@ -1374,7 +1373,7 @@ ActiveRecord::Schema.define(:version => 20160202034530) do t.integer "changeset_num", :default => 0 t.integer "board_message_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.datetime "commit_time" end