X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/32f86316712b8b781dfc2ffde0a5b88b742a6627..357060d96faad761a677b1027fa42c25805bac01:/db/migrate/046_alter_user_roles_and_blocks.rb?ds=sidebyside diff --git a/db/migrate/046_alter_user_roles_and_blocks.rb b/db/migrate/046_alter_user_roles_and_blocks.rb index db0813e33..cbd95018d 100644 --- a/db/migrate/046_alter_user_roles_and_blocks.rb +++ b/db/migrate/046_alter_user_roles_and_blocks.rb @@ -1,6 +1,9 @@ -require 'lib/migrate' +require "migrate" + +class AlterUserRolesAndBlocks < ActiveRecord::Migration[4.2] + class UserRole < ActiveRecord::Base + end -class AlterUserRolesAndBlocks < ActiveRecord::Migration def self.up # the initial granter IDs can be "self" - there are none of these # in the current live DB, but there may be some in people's own local @@ -8,7 +11,7 @@ class AlterUserRolesAndBlocks < ActiveRecord::Migration add_column :user_roles, :granter_id, :bigint UserRole.update_all("granter_id = user_id") change_column :user_roles, :granter_id, :bigint, :null => false - add_foreign_key :user_roles, [:granter_id], :users, [:id] + add_foreign_key :user_roles, :users, :column => :granter_id, :name => "user_roles_granter_id_fkey" # make sure that [user_id, role] is unique add_index :user_roles, [:user_id, :role], :name => "user_roles_id_role_unique", :unique => true @@ -21,9 +24,9 @@ class AlterUserRolesAndBlocks < ActiveRecord::Migration end def self.down - remove_column :user_roles, :granter_id - remove_index :user_roles, :name => "user_roles_id_role_unique" - rename_column :user_blocks, :creator_id, :moderator_id rename_column :user_blocks, :ends_at, :end_at + rename_column :user_blocks, :creator_id, :moderator_id + remove_index :user_roles, :name => "user_roles_id_role_unique" + remove_column :user_roles, :granter_id end end