Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / priv / repo / migrations / 20190213185503_change_apps_scopes_to_varchar_array.exs
1 defmodule Pleroma.Repo.Migrations.ChangeAppsScopesToVarcharArray do
2 use Ecto.Migration
3
4 @alter_apps_scopes "ALTER TABLE apps ALTER COLUMN scopes"
5
6 def up do
7 execute "#{@alter_apps_scopes} TYPE varchar(255)[] USING string_to_array(scopes, ',')::varchar(255)[];"
8 execute "#{@alter_apps_scopes} SET DEFAULT ARRAY[]::character varying[];"
9 execute "#{@alter_apps_scopes} SET NOT NULL;"
10 end
11
12 def down do
13 execute "#{@alter_apps_scopes} DROP NOT NULL;"
14 execute "#{@alter_apps_scopes} DROP DEFAULT;"
15 execute "#{@alter_apps_scopes} TYPE varchar(255) USING array_to_string(scopes, ',')::varchar(255);"
16 end
17 end