]> git.openstreetmap.org Git - rails.git/blob - db/migrate/054_refactor_map_bug_tables.rb
Switch back to links for sharing
[rails.git] / db / migrate / 054_refactor_map_bug_tables.rb
1 require 'migrate'
2
3 class RefactorMapBugTables < ActiveRecord::Migration
4   def self.up
5     create_table :map_bug_comment do |t|
6       t.column :id, :bigint, :null => false
7       t.column :bug_id, :bigint, :null => false
8       t.boolean :visible, :null => false 
9       t.datetime :date_created, :null => false
10       t.string :commenter_name
11       t.string :commenter_ip
12       t.column :commenter_id, :bigint
13       t.string :comment
14     end
15
16     remove_column :map_bugs, :text 
17
18     add_index :map_bug_comment, [:bug_id], :name => "map_bug_comment_id_idx"
19
20     add_foreign_key :map_bug_comment, [:bug_id], :map_bugs, [:id]
21     add_foreign_key :map_bug_comment, [:commenter_id], :users, [:id]
22   end
23
24   def self.down
25     remove_foreign_key :map_bug_comment, [:commenter_id]
26     remove_foreign_key :map_bug_comment, [:bug_id]
27
28     remove_index :map_bugs, :name => "map_bug_comment_id_idx"
29
30     add_column :map_bugs, :text, :string
31
32     drop_table :map_bug_comment
33   end
34 end