Skip to content

Commit c61eeee

Browse files
authored
Merge pull request #3550 from rubyforgood/3540-fix-bad-roles
3540: Fix bad user roles
2 parents 39fdaa7 + 57d835f commit c61eeee

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class FixBadUserRoles < ActiveRecord::Migration[7.0]
2+
def change
3+
bad_roles = Role.all.select { |r| r.resource_type && r.resource.nil? }
4+
5+
bad_roles.each do |role|
6+
UsersRole.where(role_id: role.id).destroy_all
7+
role.destroy
8+
end
9+
end
10+
end

db/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.0].define(version: 2023_03_16_135543) do
13+
ActiveRecord::Schema[7.0].define(version: 2023_04_21_202218) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "plpgsql"
1616

0 commit comments

Comments
 (0)