-- Keep clustering run filter constraints aligned with the Java DOC enum values.
-- V32 added TED_NOTICE_LOT to doc.doc_document, but cluster runs persist their
-- own optional document_type filter and therefore need the same enum expansion.

ALTER TABLE doc.doc_embedding_cluster_run
    DROP CONSTRAINT IF EXISTS doc_embedding_cluster_run_document_type_check;

ALTER TABLE doc.doc_embedding_cluster_run
    ADD CONSTRAINT doc_embedding_cluster_run_document_type_check
    CHECK (
        document_type IS NULL OR document_type IN (
            'TED_PACKAGE',
            'TED_NOTICE',
            'TED_NOTICE_LOT',
            'TIME_ENTRY',
            'EMAIL',
            'MIME_MESSAGE',
            'PDF',
            'DOCX',
            'HTML',
            'XML_GENERIC',
            'TEXT',
            'MARKDOWN',
            'ZIP_ARCHIVE',
            'GENERIC_BINARY',
            'UNKNOWN'
        )
    );

ALTER TABLE doc.doc_embedding_cluster_run
    DROP CONSTRAINT IF EXISTS doc_embedding_cluster_run_document_family_check;

ALTER TABLE doc.doc_embedding_cluster_run
    ADD CONSTRAINT doc_embedding_cluster_run_document_family_check
    CHECK (
        document_family IS NULL OR document_family IN (
            'PROCUREMENT',
            'TIME',
            'MAIL',
            'ATTACHMENT',
            'KNOWLEDGE',
            'GENERIC'
        )
    );

ALTER TABLE doc.doc_embedding_cluster_run
    DROP CONSTRAINT IF EXISTS doc_embedding_cluster_run_representation_type_check;

ALTER TABLE doc.doc_embedding_cluster_run
    ADD CONSTRAINT doc_embedding_cluster_run_representation_type_check
    CHECK (
        representation_type IS NULL OR representation_type IN (
            'FULLTEXT',
            'SEMANTIC_TEXT',
            'SUMMARY',
            'TITLE_ABSTRACT',
            'CHUNK',
            'METADATA_ENRICHED',
            'ATTACHMENT_ROLLUP'
        )
    );
