diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-11-02 16:34:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-02 16:34:47 +0100 |
commit | cb27d8999798d96c17f84a705639fc59f9d12d14 (patch) | |
tree | 856d9b0dd9d5fedea4e52fb111ddbc3743d23e10 /db | |
parent | 0f5e6dd02b9434f66c2f19715b0f1318c5d721ed (diff) |
Change migration to migrate admins to Owner role rather than Admin role (#19671)
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20220617202502_migrate_roles.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/db/post_migrate/20220617202502_migrate_roles.rb b/db/post_migrate/20220617202502_migrate_roles.rb index b7a7b2201..950699d9c 100644 --- a/db/post_migrate/20220617202502_migrate_roles.rb +++ b/db/post_migrate/20220617202502_migrate_roles.rb @@ -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 |