blob: 15a0192e20a8c3eda6ba7592742ac48b15f645af (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 | # Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.ChangeAppsScopesToVarcharArray do
  use Ecto.Migration
  @alter_apps_scopes "ALTER TABLE apps ALTER COLUMN scopes"
  def up do
    execute(
      "#{@alter_apps_scopes} TYPE varchar(255)[] USING string_to_array(scopes, ',')::varchar(255)[];"
    )
    execute("#{@alter_apps_scopes} SET DEFAULT ARRAY[]::character varying[];")
    execute("#{@alter_apps_scopes} SET NOT NULL;")
  end
  def down do
    execute("#{@alter_apps_scopes} DROP NOT NULL;")
    execute("#{@alter_apps_scopes} DROP DEFAULT;")
    execute(
      "#{@alter_apps_scopes} TYPE varchar(255) USING array_to_string(scopes, ',')::varchar(255);"
    )
  end
end
 |