20220611212541_add_role_id_to_users.rb 350 B

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