-- Protected rollback for migration 006.
-- Refuses to remove persisted report manifests.

BEGIN;

DO $$
BEGIN
    IF EXISTS (SELECT 1 FROM finance.report_channel_manifest) THEN
        RAISE EXCEPTION
            'refusing rollback: migration 006 data exists';
    END IF;
END;
$$;

DROP TRIGGER monthly_report_channel_manifest_guard
    ON finance.report_versions;
DROP FUNCTION finance.validate_monthly_report_channel_manifest();

DROP TRIGGER published_report_channel_manifest_guard
    ON finance.report_channel_manifest;
DROP FUNCTION finance.protect_published_report_channel_manifest();

DROP TRIGGER report_channel_manifest_parent_guard
    ON finance.report_channel_manifest;
DROP FUNCTION finance.validate_report_channel_manifest_parent();

DROP TABLE finance.report_channel_manifest;

COMMIT;
