Fixed `scopes` of apps / authorizations / tokens from apps initially created with...
authorIvan Tashkinov <ivantashkinov@gmail.com>
Fri, 22 Feb 2019 11:00:18 +0000 (14:00 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Fri, 22 Feb 2019 11:00:18 +0000 (14:00 +0300)
priv/repo/migrations/20190222104808_data_migration_normalize_scopes.exs [new file with mode: 0644]

diff --git a/priv/repo/migrations/20190222104808_data_migration_normalize_scopes.exs b/priv/repo/migrations/20190222104808_data_migration_normalize_scopes.exs
new file mode 100644 (file)
index 0000000..d44e509
--- /dev/null
@@ -0,0 +1,11 @@
+defmodule Pleroma.Repo.Migrations.DataMigrationNormalizeScopes do
+  use Ecto.Migration
+
+  def up do
+    for t <- [:apps, :oauth_authorizations, :oauth_tokens] do
+      execute "UPDATE #{t} SET scopes = string_to_array(array_to_string(scopes, ' '), ' ');"
+    end
+  end
+
+  def down, do: :noop
+end