Make actors deletion cascade to followers

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-10-23 16:02:01 +02:00
parent 221d10cd85
commit 0f67256814
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -0,0 +1,23 @@
defmodule Mobilizon.Storage.Repo.Migrations.DeleteActorsCascadeToFollowers do
use Ecto.Migration
def up do
drop(constraint(:followers, "followers_actor_id_fkey"))
drop(constraint(:followers, "followers_target_actor_id_fkey"))
alter table(:followers) do
modify(:actor_id, references(:actors, on_delete: :delete_all))
modify(:target_actor_id, references(:actors, on_delete: :delete_all))
end
end
def down do
drop(constraint(:followers, "followers_actor_id_fkey"))
drop(constraint(:followers, "followers_target_actor_id_fkey"))
alter table(:followers) do
modify(:actor_id, references(:actors, on_delete: :nothing))
modify(:target_actor_id, references(:actors, on_delete: :nothing))
end
end
end