summaryrefslogtreecommitdiff
path: root/priv
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2020-09-03 10:34:06 -0500
committerMark Felder <feld@FreeBSD.org>2020-09-03 10:34:06 -0500
commit85446cc30c97a326d90b4ef719ba2e54c2ad423f (patch)
treecaa8e1268cbab2a09e414b85d2ce52b24249d0da /priv
parent6ce28c409137972ee9b105b9d7ab4a0fd2a0d08b (diff)
parent9433311923d4b41b057ce6cb1632ff27d46919b4 (diff)
downloadpleroma-85446cc30c97a326d90b4ef719ba2e54c2ad423f.tar.gz
pleroma-85446cc30c97a326d90b4ef719ba2e54c2ad423f.zip
Merge branch 'develop' into media-preview-proxy
Diffstat (limited to 'priv')
-rw-r--r--priv/repo/migrations/20200831142509_chat_constraints.exs22
-rw-r--r--priv/repo/migrations/20200901061256_ensure_bio_is_string.exs7
-rw-r--r--priv/repo/migrations/20200901061637_bio_set_not_null.exs10
3 files changed, 39 insertions, 0 deletions
diff --git a/priv/repo/migrations/20200831142509_chat_constraints.exs b/priv/repo/migrations/20200831142509_chat_constraints.exs
new file mode 100644
index 000000000..868a40a45
--- /dev/null
+++ b/priv/repo/migrations/20200831142509_chat_constraints.exs
@@ -0,0 +1,22 @@
+defmodule Pleroma.Repo.Migrations.ChatConstraints do
+ use Ecto.Migration
+
+ def change do
+ remove_orphans = """
+ delete from chats where not exists(select id from users where ap_id = chats.recipient);
+ """
+
+ execute(remove_orphans)
+
+ drop(constraint(:chats, "chats_user_id_fkey"))
+
+ alter table(:chats) do
+ modify(:user_id, references(:users, type: :uuid, on_delete: :delete_all))
+
+ modify(
+ :recipient,
+ references(:users, column: :ap_id, type: :string, on_delete: :delete_all)
+ )
+ end
+ end
+end
diff --git a/priv/repo/migrations/20200901061256_ensure_bio_is_string.exs b/priv/repo/migrations/20200901061256_ensure_bio_is_string.exs
new file mode 100644
index 000000000..0e3bb3c81
--- /dev/null
+++ b/priv/repo/migrations/20200901061256_ensure_bio_is_string.exs
@@ -0,0 +1,7 @@
+defmodule Pleroma.Repo.Migrations.EnsureBioIsString do
+ use Ecto.Migration
+
+ def change do
+ execute("update users set bio = '' where bio is null", "")
+ end
+end
diff --git a/priv/repo/migrations/20200901061637_bio_set_not_null.exs b/priv/repo/migrations/20200901061637_bio_set_not_null.exs
new file mode 100644
index 000000000..e3a67d4e7
--- /dev/null
+++ b/priv/repo/migrations/20200901061637_bio_set_not_null.exs
@@ -0,0 +1,10 @@
+defmodule Pleroma.Repo.Migrations.BioSetNotNull do
+ use Ecto.Migration
+
+ def change do
+ execute(
+ "alter table users alter column bio set not null",
+ "alter table users alter column bio drop not null"
+ )
+ end
+end