2018-06-20 18:02:33 +02:00
|
|
|
class RolifyCreateRoles < ActiveRecord::Migration[5.0]
|
2017-01-23 16:59:04 +01:00
|
|
|
def change
|
|
|
|
create_table(:roles) do |t|
|
|
|
|
t.string :name
|
|
|
|
t.references :resource, polymorphic: true
|
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
|
|
|
create_table(:clients_roles, id: false) do |t|
|
|
|
|
t.references :client
|
|
|
|
t.references :role
|
|
|
|
end
|
|
|
|
|
|
|
|
add_index(:roles, :name)
|
|
|
|
add_index(:roles, [ :name, :resource_type, :resource_id ])
|
|
|
|
add_index(:clients_roles, [ :client_id, :role_id ])
|
|
|
|
end
|
|
|
|
end
|