summaryrefslogtreecommitdiff
path: root/priv/repo/migrations
diff options
context:
space:
mode:
authorMaksim Pechnikov <parallel588@gmail.com>2020-01-27 15:20:47 +0300
committerMaksim Pechnikov <parallel588@gmail.com>2020-01-27 15:20:47 +0300
commite442ea5722404ca551135b6f4767c016952bbda3 (patch)
tree91bb371d96fbc8b46d59c378f6dd690ba30f3da3 /priv/repo/migrations
parent6fbafb1cdcba3dc2a7e8b9718e295c9811a726d9 (diff)
parent0b582d415ba5215495047ddae1cb4e4fc1e016e6 (diff)
downloadpleroma-e442ea5722404ca551135b6f4767c016952bbda3.tar.gz
pleroma-e442ea5722404ca551135b6f4767c016952bbda3.zip
Merge branch 'develop' into issue/1276
Diffstat (limited to 'priv/repo/migrations')
-rw-r--r--priv/repo/migrations/20191123030554_add_activitypub_actor_type.exs9
-rw-r--r--priv/repo/migrations/20191203043610_create_report_notes.exs13
-rw-r--r--priv/repo/migrations/20191220174645_add_scopes_to_pleroma_feo_auth_records.exs17
3 files changed, 39 insertions, 0 deletions
diff --git a/priv/repo/migrations/20191123030554_add_activitypub_actor_type.exs b/priv/repo/migrations/20191123030554_add_activitypub_actor_type.exs
new file mode 100644
index 000000000..76d3b32c4
--- /dev/null
+++ b/priv/repo/migrations/20191123030554_add_activitypub_actor_type.exs
@@ -0,0 +1,9 @@
+defmodule Pleroma.Repo.Migrations.AddActivitypubActorType do
+ use Ecto.Migration
+
+ def change do
+ alter table("users") do
+ add(:actor_type, :string, null: false, default: "Person")
+ end
+ end
+end
diff --git a/priv/repo/migrations/20191203043610_create_report_notes.exs b/priv/repo/migrations/20191203043610_create_report_notes.exs
new file mode 100644
index 000000000..a4f8c096d
--- /dev/null
+++ b/priv/repo/migrations/20191203043610_create_report_notes.exs
@@ -0,0 +1,13 @@
+defmodule Pleroma.Repo.Migrations.CreateReportNotes do
+ use Ecto.Migration
+
+ def change do
+ create_if_not_exists table(:report_notes) do
+ add(:user_id, references(:users, type: :uuid))
+ add(:activity_id, references(:activities, type: :uuid))
+ add(:content, :string)
+
+ timestamps()
+ end
+ end
+end
diff --git a/priv/repo/migrations/20191220174645_add_scopes_to_pleroma_feo_auth_records.exs b/priv/repo/migrations/20191220174645_add_scopes_to_pleroma_feo_auth_records.exs
new file mode 100644
index 000000000..6b160ad16
--- /dev/null
+++ b/priv/repo/migrations/20191220174645_add_scopes_to_pleroma_feo_auth_records.exs
@@ -0,0 +1,17 @@
+defmodule Pleroma.Repo.Migrations.AddScopesToPleromaFEOAuthRecords do
+ use Ecto.Migration
+
+ def up do
+ update_scopes_clause = "SET scopes = '{read,write,follow,push,admin}'"
+ apps_where = "WHERE apps.client_name like 'PleromaFE_%' or apps.client_name like 'AdminFE_%'"
+ app_id_subquery_where = "WHERE app_id IN (SELECT apps.id FROM apps #{apps_where})"
+
+ execute("UPDATE apps #{update_scopes_clause} #{apps_where}")
+
+ for table <- ["oauth_authorizations", "oauth_tokens"] do
+ execute("UPDATE #{table} #{update_scopes_clause} #{app_id_subquery_where}")
+ end
+ end
+
+ def down, do: :noop
+end