Add migration to remove invalid activity expirations
authorMark Felder <feld@FreeBSD.org>
Sat, 8 Aug 2020 17:33:37 +0000 (12:33 -0500)
committerMark Felder <feld@FreeBSD.org>
Sat, 8 Aug 2020 17:33:37 +0000 (12:33 -0500)
priv/repo/migrations/20200808173046_only_expire_creates.exs [new file with mode: 0644]

diff --git a/priv/repo/migrations/20200808173046_only_expire_creates.exs b/priv/repo/migrations/20200808173046_only_expire_creates.exs
new file mode 100644 (file)
index 0000000..5a34dc7
--- /dev/null
@@ -0,0 +1,20 @@
+defmodule Pleroma.Repo.Migrations.OnlyExpireCreates do
+  use Ecto.Migration
+
+  def up do
+    statement = """
+    DELETE FROM
+      activity_expirations A USING activities B
+    WHERE
+      A.activity_id = B.id
+      AND B.local = false
+      AND B.data->>'type' != 'Create';
+    """
+
+    execute(statement)
+  end
+
+  def down do
+    :ok
+  end
+end