Class: PapeelCreateRoles

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

Instance Method Summary collapse

Instance Method Details

#changeObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/generators/papeel/migration/templates/migration.rb', line 2

def change
  create_table :papeel_roles do |t|
    t.belongs_to :user, index: true, foreign_key: true
    t.string :name
    t.belongs_to :resource, polymorphic: true, index: true
    t.timestamps null: false
  end

  add_index :papeel_roles, :name
  add_index :papeel_roles, [:user_id, :name]
  add_index :papeel_roles, [:resource_type, :resource_id, :name]
end