1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/db/migrate/20181129231814_rolify_create_roles.rb
2018-11-30 04:41:06 +05:00

24 lines
594 B
Ruby

# frozen_string_literal: true
class RolifyCreateRoles < ActiveRecord::Migration[5.2]
def change
create_table :roles do |t|
t.timestamps null: false
t.string :name
t.references :resource, polymorphic: true
t.index %i[name resource_type resource_id], unique: true
end
create_table :user_roles do |t|
t.timestamps null: false
t.references :user, null: false
t.references :role, null: false
t.index %i[user_id role_id], unique: true
end
add_foreign_key :user_roles, :users
add_foreign_key :user_roles, :roles
end
end