logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

20191220174645_add_scopes_to_pleroma_feo_auth_records.exs (774B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Repo.Migrations.AddScopesToPleromaFEOAuthRecords do
  5. use Ecto.Migration
  6. def up do
  7. update_scopes_clause = "SET scopes = '{read,write,follow,push,admin}'"
  8. apps_where = "WHERE apps.client_name like 'PleromaFE_%' or apps.client_name like 'AdminFE_%'"
  9. app_id_subquery_where = "WHERE app_id IN (SELECT apps.id FROM apps #{apps_where})"
  10. execute("UPDATE apps #{update_scopes_clause} #{apps_where}")
  11. for table <- ["oauth_authorizations", "oauth_tokens"] do
  12. execute("UPDATE #{table} #{update_scopes_clause} #{app_id_subquery_where}")
  13. end
  14. end
  15. def down, do: :noop
  16. end