about summary refs log tree commit diff
path: root/db/migrate/20220611212541_add_role_id_to_users.rb
blob: 2fda647d4c313a5909267ad0d2d6bd188e67531d (plain) (blame)
1
2
3
4
5
6
7
8
class AddRoleIdToUsers < ActiveRecord::Migration[6.1]
  disable_ddl_transaction!

  def change
    safety_assured { add_reference :users, :role, foreign_key: { to_table: 'user_roles', on_delete: :nullify }, index: false }
    add_index :users, :role_id, algorithm: :concurrently, where: 'role_id IS NOT NULL'
  end
end