logo

pleroma

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

20190213185503_change_apps_scopes_to_varchar_array.exs (826B)


  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.ChangeAppsScopesToVarcharArray do
  5. use Ecto.Migration
  6. @alter_apps_scopes "ALTER TABLE apps ALTER COLUMN scopes"
  7. def up do
  8. execute(
  9. "#{@alter_apps_scopes} TYPE varchar(255)[] USING string_to_array(scopes, ',')::varchar(255)[];"
  10. )
  11. execute("#{@alter_apps_scopes} SET DEFAULT ARRAY[]::character varying[];")
  12. execute("#{@alter_apps_scopes} SET NOT NULL;")
  13. end
  14. def down do
  15. execute("#{@alter_apps_scopes} DROP NOT NULL;")
  16. execute("#{@alter_apps_scopes} DROP DEFAULT;")
  17. execute(
  18. "#{@alter_apps_scopes} TYPE varchar(255) USING array_to_string(scopes, ',')::varchar(255);"
  19. )
  20. end
  21. end