1
0
Fork 0
dokkan-data-rails/db/migrate/20151008192100_rolify_create_roles.rb

20 lines
461 B
Ruby
Raw Permalink Normal View History

2015-10-08 15:18:21 -04:00
class RolifyCreateRoles < ActiveRecord::Migration
def change
create_table(:roles) do |t|
t.string :name
t.references :resource, :polymorphic => true
t.timestamps
end
create_table(:users_roles, :id => false) do |t|
t.references :user
t.references :role
end
add_index(:roles, :name)
add_index(:roles, [ :name, :resource_type, :resource_id ])
add_index(:users_roles, [ :user_id, :role_id ])
end
end