-- Phase 2: Vectorization decoupling support in the generic DOC schema
-- Adds safety constraints and indexes for representation-based embedding processing.

CREATE UNIQUE INDEX IF NOT EXISTS uq_doc_embedding_representation_model
    ON DOC.doc_embedding(representation_id, model_id);

CREATE INDEX IF NOT EXISTS idx_doc_embedding_status_created
    ON DOC.doc_embedding(embedding_status, created_at);

CREATE INDEX IF NOT EXISTS idx_doc_embedding_status_updated
    ON DOC.doc_embedding(embedding_status, updated_at);

CREATE INDEX IF NOT EXISTS idx_doc_text_repr_document_primary
    ON DOC.doc_text_representation(document_id, is_primary);
