summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2019-02-14 00:29:29 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2019-02-14 00:29:29 +0300
commit063baca5e4f3a100c0d45dffb14e4968599ef43b (patch)
tree007c44ff7cd2c90b2e1c18d7ced704448fea5601 /priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs
parenta337bd114c3cbbb8e8270ec56a012e82f84df808 (diff)
downloadpleroma-063baca5e4f3a100c0d45dffb14e4968599ef43b.tar.gz
pleroma-063baca5e4f3a100c0d45dffb14e4968599ef43b.zip
[#468] User UI for OAuth permissions restriction. Standardized storage format for `scopes` fields, updated usages.
Diffstat (limited to 'priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs')
-rw-r--r--priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs17
1 files changed, 17 insertions, 0 deletions
diff --git a/priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs b/priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs
new file mode 100644
index 000000000..72decd401
--- /dev/null
+++ b/priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs
@@ -0,0 +1,17 @@
+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