mirror of https://github.com/mastodon/mastodon
Change `read:me` scope to `profile` scope (#30357)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>pull/30576/head
parent
569b7d2f25
commit
e02d23b549
@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ChangeReadMeScopeToProfile < ActiveRecord::Migration[7.1]
|
||||
def up
|
||||
replace_scopes('read:me', 'profile')
|
||||
end
|
||||
|
||||
def down
|
||||
replace_scopes('profile', 'read:me')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def replace_scopes(old_scope, new_scope)
|
||||
Doorkeeper::Application.where("scopes LIKE '%#{old_scope}%'").in_batches do |applications|
|
||||
applications.update_all("scopes = replace(scopes, '#{old_scope}', '#{new_scope}')")
|
||||
end
|
||||
|
||||
Doorkeeper::AccessToken.where("scopes LIKE '%#{old_scope}%'").in_batches do |access_tokens|
|
||||
access_tokens.update_all("scopes = replace(scopes, '#{old_scope}', '#{new_scope}')")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue