mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 14:05:42 +01:00
Change migration to migrate admins to Owner role rather than Admin role (#19671)
This commit is contained in:
parent
0f5e6dd02b
commit
cb27d89997
1 changed files with 4 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue