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 00000000..598f5b51 --- /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 8c3bdca4..9178151a 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"