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