don't persist undo of follows (#149)
[akkoma] / priv / repo / migrations / 20220805123645_remove_remote_cancelled_follow_requests.exs
diff --git a/priv/repo/migrations/20220805123645_remove_remote_cancelled_follow_requests.exs b/priv/repo/migrations/20220805123645_remove_remote_cancelled_follow_requests.exs
new file mode 100644 (file)
index 0000000..3159843
--- /dev/null
@@ -0,0 +1,35 @@
+defmodule Pleroma.Repo.Migrations.RemoveRemoteCancelledFollowRequests do
+  use Ecto.Migration
+
+  def up do
+    statement = """
+    DELETE FROM
+        activities
+    WHERE
+        (data->>'type') = 'Follow'
+    AND
+        (data->>'state') = 'cancelled'
+    AND
+        local = false;
+    """
+
+    execute(statement)
+
+    statement = """
+    DELETE FROM
+        activities
+    WHERE
+        (data->>'type') = 'Undo'
+    AND
+        (data->'object'->>'type') = 'Follow'
+    AND
+        local = false;
+    """
+
+    execute(statement)
+  end
+
+  def down do
+    :ok
+  end
+end