20220611212541_add_role_id_to_users.rb 319 B

12345678
  1. class AddRoleIdToUsers < ActiveRecord::Migration[6.1]
  2. disable_ddl_transaction!
  3. def change
  4. safety_assured { add_reference :users, :role, foreign_key: { to_table: 'user_roles', on_delete: :nullify }, index: false }
  5. add_index :users, :role_id, algorithm: :concurrently, where: 'role_id IS NOT NULL'
  6. end
  7. end