Class: UserRoles

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/roles/templates/migrations/user_roles.rb

Instance Method Summary collapse

Instance Method Details

#downObject



16
17
18
19
# File 'lib/generators/roles/templates/migrations/user_roles.rb', line 16

def down
  drop_table :roles_users
  drop_table :roles
end

#upObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/generators/roles/templates/migrations/user_roles.rb', line 4

def up
  create_table :roles do |t|
    t.string :name
  end
  create_table :roles_users, id: false do |t|
    t.references :role
    t.references :user
  end
  add_index :roles_users, %i[role_id user_id]
  add_index :roles_users, %i[user_id role_id]
end