feat(db): Add migration 010 for chunk config tracking columns

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>
This commit is contained in:
Taylor Eernisse
2026-02-03 09:34:48 -05:00
parent 51c370fac2
commit 2a52594a60
2 changed files with 22 additions and 0 deletions

View File

@@ -10,6 +10,10 @@ use tracing::{debug, info};
use super::error::{LoreError, Result};
/// Latest schema version, derived from the embedded migrations count.
/// Used by the health check to verify databases are up-to-date.
pub const LATEST_SCHEMA_VERSION: i32 = MIGRATIONS.len() as i32;
/// Embedded migrations - compiled into the binary.
const MIGRATIONS: &[(&str, &str)] = &[
("001", include_str!("../../migrations/001_initial.sql")),
@@ -39,6 +43,10 @@ const MIGRATIONS: &[(&str, &str)] = &[
"009",
include_str!("../../migrations/009_embeddings.sql"),
),
(
"010",
include_str!("../../migrations/010_chunk_config.sql"),
),
];
/// Create a database connection with production-grade pragmas.