Class: RoleableCreateRolesAndAppliedRoles

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/roleable/install/templates/migration.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/roleable/install/templates/migration.rb', line 3

def change
  create_table :roles do |t|
    t.string :name
    t.timestamps
  end

  create_table :applied_roles do |t|
    t.references :subject
    t.references :role
    t.references :resource, :polymorphic => true
    t.timestamps
  end

  add_index :applied_roles, :subject_id
  add_index :applied_roles, [:resource_type, :resource_id]
end