From 22b2451edd9e42ba96bf7f815383b2eaad9a5e56 Mon Sep 17 00:00:00 2001 From: faried nawaz Date: Wed, 21 Apr 2021 02:37:03 +0500 Subject: [PATCH] migration: add on_delete: :delete_all to hashtags object_id fk --- ...204354_delete_hashtags_objects_cascade.exs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 priv/repo/migrations/20210420204354_delete_hashtags_objects_cascade.exs diff --git a/priv/repo/migrations/20210420204354_delete_hashtags_objects_cascade.exs b/priv/repo/migrations/20210420204354_delete_hashtags_objects_cascade.exs new file mode 100644 index 000000000..f4ebf53d6 --- /dev/null +++ b/priv/repo/migrations/20210420204354_delete_hashtags_objects_cascade.exs @@ -0,0 +1,19 @@ +defmodule Pleroma.Repo.Migrations.DeleteHashtagsObjectsCascade do + use Ecto.Migration + + def up do + execute("ALTER TABLE hashtags_objects DROP CONSTRAINT hashtags_objects_object_id_fkey") + + alter table(:hashtags_objects) do + modify(:object_id, references(:objects, on_delete: :delete_all)) + end + end + + def down do + execute("ALTER TABLE hashtags_objects DROP CONSTRAINT hashtags_objects_object_id_fkey") + + alter table(:hashtags_objects) do + modify(:object_id, references(:objects, on_delete: :nothing)) + end + end +end -- 2.45.2