GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#496)
by Jesus
03:28
created

RolifyCreateRoles   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A change() 0 21 1
1
# frozen_string_literal: true
2
3
class RolifyCreateRoles < ActiveRecord::Migration[5.0]
4
  def change
5
    create_table(:roles) do |t|
6
      t.string :name
7
      t.references :resource, polymorphic: true
8
9
      t.timestamps
10
    end
11
12
    create_table(:users_roles, id: false) do |t|
13
      t.references :user
14
      t.references :role
15
    end
16
17
    add_index(:roles, :name)
18
    add_index(:roles, [:name, :resource_type, :resource_id])
19
    add_index(:users_roles, [:user_id, :role_id])
20
21
    User.all.each do |user|
22
      user.add_role(:user) if user.roles.blank?
23
    end
24
  end
25
end
26