From 846034404303f51113ca3d6da51832034002e979 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 3 Jun 2014 11:52:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA=E5=8C=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20140603033359_add_boards_type_to_boards.rb | 13 +++++++++++++ db/schema.rb | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20140603033359_add_boards_type_to_boards.rb diff --git a/db/migrate/20140603033359_add_boards_type_to_boards.rb b/db/migrate/20140603033359_add_boards_type_to_boards.rb new file mode 100644 index 000000000..598f5b517 --- /dev/null +++ b/db/migrate/20140603033359_add_boards_type_to_boards.rb @@ -0,0 +1,13 @@ +class AddBoardsTypeToBoards < ActiveRecord::Migration + def change + add_column :boards, :course_id, :int + + Board.all.each do |board| + project = Project.find_by_id(board.project_id) + if project && project.project_type == 1 + board.course_id = board.project_id + board.save + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8c3bdca4f..9178151a7 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 => 20140530102015) do +ActiveRecord::Schema.define(:version => 20140603033360) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -119,6 +119,7 @@ ActiveRecord::Schema.define(:version => 20140530102015) do t.integer "messages_count", :default => 0, :null => false t.integer "last_message_id" t.integer "parent_id" + t.integer "course_id" end add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id"