Don't persist local undone follow (#194)
[akkoma] / priv / repo / migrations / 20220831170605_remove_local_cancelled_follows.exs
diff --git a/priv/repo/migrations/20220831170605_remove_local_cancelled_follows.exs b/priv/repo/migrations/20220831170605_remove_local_cancelled_follows.exs
new file mode 100644 (file)
index 0000000..16597f8
--- /dev/null
@@ -0,0 +1,22 @@
+defmodule Pleroma.Repo.Migrations.RemoveLocalCancelledFollows do
+  use Ecto.Migration
+
+  def up do
+    statement = """
+    DELETE FROM
+        activities
+    WHERE
+        (data->>'type') = 'Follow'
+    AND
+        (data->>'state') = 'cancelled'
+    AND
+        local = true;
+    """
+
+    execute(statement)
+  end
+
+  def down do
+    :ok
+  end
+end