2020-03-24 16:45:27 +01:00
|
|
|
# frozen_string_literal:true
|
|
|
|
|
|
|
|
class RolifyCreateRoles < ActiveRecord::Migration[4.2]
|
2015-05-05 03:10:25 +02:00
|
|
|
def change
|
|
|
|
create_table(:roles) do |t|
|
|
|
|
t.string :name
|
2020-03-24 16:45:27 +01:00
|
|
|
t.references :resource, polymorphic: true
|
2015-05-05 03:10:25 +02:00
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
2020-03-24 16:45:27 +01:00
|
|
|
create_table(:users_roles, id: false) do |t|
|
2015-05-05 03:10:25 +02:00
|
|
|
t.references :user
|
|
|
|
t.references :role
|
|
|
|
end
|
|
|
|
|
|
|
|
add_index(:roles, :name)
|
2020-03-24 16:45:27 +01:00
|
|
|
add_index(:roles, %i[name resource_type resource_id])
|
|
|
|
add_index(:users_roles, %i[user_id role_id])
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|
|
|
|
end
|