-- 048: Expand processing_path CHECK constraint for new pipeline paths
-- New values: prefilter_skip, no_control, store_failed, error
-- Safe: only runs if the table exists (may not exist on all environments)

DO $$
BEGIN
    IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'canonical_processed_chunks') THEN
        ALTER TABLE canonical_processed_chunks
            DROP CONSTRAINT IF EXISTS canonical_processed_chunks_processing_path_check;
        ALTER TABLE canonical_processed_chunks
            ADD CONSTRAINT canonical_processed_chunks_processing_path_check
            CHECK (processing_path IN (
                'structured',
                'llm_reform',
                'skipped',
                'prefilter_skip',
                'no_control',
                'store_failed',
                'error'
            ));
    END IF;
END $$;
