1 defmodule Pleroma.Repo.Migrations.ChatConstraints do
6 delete from chats where not exists(select id from users where ap_id = chats.recipient);
9 execute(remove_orphans)
11 drop(constraint(:chats, "chats_user_id_fkey"))
13 alter table(:chats) do
14 modify(:user_id, references(:users, type: :uuid, on_delete: :delete_all))
18 references(:users, column: :ap_id, type: :string, on_delete: :delete_all)