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