Class: CreateUserRoles

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

Instance Method Summary collapse

Instance Method Details

#changeObject



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

def change
  create_table :user_roles do |t|
    t.integer :user_id
    t.integer :role_id

    t.timestamps
  end

  add_index :user_roles, :user_id
  add_index :user_roles, :role_id
  add_index :user_roles, [:user_id, :role_id], unique: true
end