Add chunk_max_bytes and chunk_count columns to embedding_metadata to support config drift detection and adaptive dedup sizing. Includes a partial index on sentinel rows (chunk_index=0) to accelerate the drift detection and max-chunk queries. Also exports LATEST_SCHEMA_VERSION as a public constant derived from the MIGRATIONS array length, replacing the previously hardcoded magic number in the health check. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
15 lines
598 B
SQL
15 lines
598 B
SQL
-- Migration 010: Chunk config tracking + adaptive dedup support
|
|
-- Schema version: 10
|
|
|
|
ALTER TABLE embedding_metadata ADD COLUMN chunk_max_bytes INTEGER;
|
|
ALTER TABLE embedding_metadata ADD COLUMN chunk_count INTEGER;
|
|
|
|
-- Partial index: accelerates drift detection and adaptive dedup queries on sentinel rows
|
|
CREATE INDEX idx_embedding_metadata_sentinel
|
|
ON embedding_metadata(document_id, chunk_index)
|
|
WHERE chunk_index = 0;
|
|
|
|
INSERT INTO schema_version (version, applied_at, description)
|
|
VALUES (10, strftime('%s', 'now') * 1000,
|
|
'Add chunk_max_bytes and chunk_count to embedding_metadata');
|