Fixing up deletes a bit (#327)
[akkoma] / priv / repo / migrations / 20221129112022_add_cascade_to_report_notes_on_activity_delete.exs
diff --git a/priv/repo/migrations/20221129112022_add_cascade_to_report_notes_on_activity_delete.exs b/priv/repo/migrations/20221129112022_add_cascade_to_report_notes_on_activity_delete.exs
new file mode 100644 (file)
index 0000000..960554a
--- /dev/null
@@ -0,0 +1,19 @@
+defmodule Pleroma.Repo.Migrations.AddCascadeToReportNotesOnActivityDelete do
+  use Ecto.Migration
+
+  def up do
+    drop(constraint(:report_notes, "report_notes_activity_id_fkey"))
+
+    alter table(:report_notes) do
+      modify(:activity_id, references(:activities, type: :uuid, on_delete: :delete_all))
+    end
+  end
+
+  def down do
+    drop(constraint(:report_notes, "report_notes_activity_id_fkey"))
+
+    alter table(:report_notes) do
+      modify(:activity_id, references(:activities, type: :uuid))
+    end
+  end
+end