diff options
| author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-08-31 20:55:05 +0000 |
|---|---|---|
| committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-08-31 20:55:05 +0000 |
| commit | 9d63b2c9db88ffdeb608df427caf2996eb0bb094 (patch) | |
| tree | 35547f73c20bd504ff4465ee0402078ba48b34df /priv | |
| parent | e0eb90f62a5c8cc14c8fd7fc82ab54342f6fe209 (diff) | |
| parent | 0b621a834acf751332f4d202bd50d4ff3e789176 (diff) | |
| download | pleroma-9d63b2c9db88ffdeb608df427caf2996eb0bb094.tar.gz pleroma-9d63b2c9db88ffdeb608df427caf2996eb0bb094.zip | |
Merge branch 'chat-relation-constraints' into 'develop'
Chats: Add cascading delete on both referenced users.
See merge request pleroma/pleroma!2934
Diffstat (limited to 'priv')
| -rw-r--r-- | priv/repo/migrations/20200831142509_chat_constraints.exs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/priv/repo/migrations/20200831142509_chat_constraints.exs b/priv/repo/migrations/20200831142509_chat_constraints.exs new file mode 100644 index 000000000..868a40a45 --- /dev/null +++ b/priv/repo/migrations/20200831142509_chat_constraints.exs @@ -0,0 +1,22 @@ +defmodule Pleroma.Repo.Migrations.ChatConstraints do + use Ecto.Migration + + def change do + remove_orphans = """ + delete from chats where not exists(select id from users where ap_id = chats.recipient); + """ + + execute(remove_orphans) + + drop(constraint(:chats, "chats_user_id_fkey")) + + alter table(:chats) do + modify(:user_id, references(:users, type: :uuid, on_delete: :delete_all)) + + modify( + :recipient, + references(:users, column: :ap_id, type: :string, on_delete: :delete_all) + ) + end + end +end |
