Skip to content
Snippets Groups Projects
Unverified Commit cb27d899 authored by Claire's avatar Claire Committed by GitHub
Browse files

Change migration to migrate admins to Owner role rather than Admin role (#19671)

parent 0f5e6dd0
No related branches found
No related tags found
No related merge requests found
......@@ -9,18 +9,19 @@ class MigrateRoles < ActiveRecord::Migration[5.2]
def up
load Rails.root.join('db', 'seeds', '03_roles.rb')
admin_role = UserRole.find_by(name: 'Admin')
owner_role = UserRole.find_by(name: 'Owner')
moderator_role = UserRole.find_by(name: 'Moderator')
User.where(admin: true).in_batches.update_all(role_id: admin_role.id)
User.where(admin: true).in_batches.update_all(role_id: owner_role.id)
User.where(moderator: true).in_batches.update_all(role_id: moderator_role.id)
end
def down
admin_role = UserRole.find_by(name: 'Admin')
owner_role = UserRole.find_by(name: 'Owner')
moderator_role = UserRole.find_by(name: 'Moderator')
User.where(role_id: admin_role.id).in_batches.update_all(admin: true) if admin_role
User.where(role_id: [admin_role.id, owner_role.id]).in_batches.update_all(admin: true) if admin_role
User.where(role_id: moderator_role.id).in_batches.update_all(moderator: true) if moderator_role
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment