-- Add ON DELETE CASCADE to document_tags and document_receivers so that
-- deleting a document automatically removes its tag and receiver associations.

ALTER TABLE public.document_tags
    DROP CONSTRAINT fkc99c5qjulwx9gru07yrhicgd2,
    ADD CONSTRAINT fkc99c5qjulwx9gru07yrhicgd2
        FOREIGN KEY (document_id) REFERENCES public.documents(id) ON DELETE CASCADE;

ALTER TABLE public.document_receivers
    DROP CONSTRAINT fks7t60twjgfmpeqcuc3g0fvjpm,
    ADD CONSTRAINT fks7t60twjgfmpeqcuc3g0fvjpm
        FOREIGN KEY (document_id) REFERENCES public.documents(id) ON DELETE CASCADE;
