X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/b5d0de88eab8b22bedec7fd7cc34552caa1584ab..a1b179fa384d689e6cb78c2b8d863621e7bff152:/db/migrate/054_refactor_map_bug_tables.rb diff --git a/db/migrate/054_refactor_map_bug_tables.rb b/db/migrate/054_refactor_map_bug_tables.rb index b45f935cc..e29ec0704 100644 --- a/db/migrate/054_refactor_map_bug_tables.rb +++ b/db/migrate/054_refactor_map_bug_tables.rb @@ -1,36 +1,35 @@ -require 'lib/migrate' +require "migrate" -class RefactorMapBugTables < ActiveRecord::Migration +class RefactorMapBugTables < ActiveRecord::Migration[5.0] def self.up - - create_table :map_bug_comment do |t| - t.column :id, :bigint, :null => false - t.column :bug_id, :bigint, :null => false - t.boolean :visible, :null => false + t.column :bug_id, :bigint, :null => false + t.boolean :visible, :null => false t.datetime :date_created, :null => false - t.string :commenter_name - t.string :commenter_ip - t.column :commenter_id, :bigint + t.string :commenter_name + t.string :commenter_ip + t.column :commenter_id, :bigint t.string :comment end - remove_column :map_bugs, :text + remove_column :map_bugs, :text + + change_column :map_bug_comment, :id, :bigint add_index :map_bug_comment, [:bug_id], :name => "map_bug_comment_id_idx" - add_foreign_key :map_bug_comment, [:bug_id], :map_bugs, [:id] - add_foreign_key :map_bug_comment, [:commenter_id], :users, [:id] + add_foreign_key :map_bug_comment, :map_bugs, :column => :bug_id, :name => "note_comments_note_id_fkey" + add_foreign_key :map_bug_comment, :users, :column => :commenter_id, :name => "note_comments_author_id_fkey" end def self.down - - add_column :map_bugs, :text, :string + remove_foreign_key :map_bug_comment, :users, :column => :commenter_id, :name => "note_comments_author_id_fkey" + remove_foreign_key :map_bug_comment, :map_bugs, :column => :bug_id, :name => "note_comments_note_id_fkey" remove_index :map_bugs, :name => "map_bug_comment_id_idx" - remove_foreign_key :map_bug_comment, [:bug_id] - remove_foreign_key :map_bug_comment, [:commenter_id] - drop_table :map_bugs_comment + add_column :map_bugs, :text, :string + + drop_table :map_bug_comment end end