-- Revert back to NO ACTION (for rollback safety)
DO $$
BEGIN
    ALTER TABLE marketing_products DROP CONSTRAINT IF EXISTS fk_marketing_products_marketing_id;

    ALTER TABLE marketing_products
        ADD CONSTRAINT fk_marketing_products_marketing_id
        FOREIGN KEY (marketing_id) REFERENCES marketings(id)
        ON DELETE NO ACTION;
END $$;

DO $$
BEGIN
    ALTER TABLE marketing_delivery_products DROP CONSTRAINT IF EXISTS fk_marketing_delivery_products_marketing_product_id;

    ALTER TABLE marketing_delivery_products
        ADD CONSTRAINT fk_marketing_delivery_products_marketing_product_id
        FOREIGN KEY (marketing_product_id) REFERENCES marketing_products(id)
        ON DELETE NO ACTION;
END $$;
