From 0254c782f5dc384dabd9bcf541471c2c0765ba22 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 28 Aug 2019 11:28:02 +0200 Subject: [PATCH] Remove events when deleting organizer Signed-off-by: Thomas Citharel --- ..._remove_events_when_deleting_organizer.exs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 priv/repo/migrations/20190823132816_remove_events_when_deleting_organizer.exs diff --git a/priv/repo/migrations/20190823132816_remove_events_when_deleting_organizer.exs b/priv/repo/migrations/20190823132816_remove_events_when_deleting_organizer.exs new file mode 100644 index 000000000..76657ecb2 --- /dev/null +++ b/priv/repo/migrations/20190823132816_remove_events_when_deleting_organizer.exs @@ -0,0 +1,19 @@ +defmodule Mobilizon.Repo.Migrations.RemoveEventsWhenDeletingOrganizer do + use Ecto.Migration + + def up do + drop(constraint(:events, "events_organizer_account_id_fkey")) + + alter table(:events) do + modify(:organizer_actor_id, references(:actors, on_delete: :delete_all)) + end + end + + def down do + drop(constraint(:events, "events_organizer_actor_id_fkey")) + + alter table(:events) do + modify(:organizer_actor_id, references(:actors, on_delete: :nothing)) + end + end +end