You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
initialize_schema ran up to eight throwaway `SELECT col ... LIMIT 1` probes on
every Database::open to detect missing columns — and open is called several
times per process, so on a fully-migrated DB this is pure wasted work every boot.
Gate the probe block on PRAGMA user_version: read it after the (still-ungated,
all-IF-NOT-EXISTS) DDL, return early when already at SCHEMA_VERSION, and stamp
the version once the column-add migrations have run. The DDL stays ungated so it
still back-fills newer objects (e.g. idx_entities_recall) on older databases.
Pre-existing databases sit at user_version=0, so they pay the probe pass exactly
once more (idempotent — columns already exist, no ALTERs fire) and are then
stamped; every subsequent open skips the block. A documented SCHEMA_VERSION
constant flags that adding a future probe requires a bump.
Addresses #208 item 4 (item 2, ONNX session cache, remains blocked by #212).
Tests: stamps_user_version_and_gates_migration_probes (fresh init stamps the
version; re-init is a data-preserving no-op) and migrates_pre_versioned_db_
missing_a_column (a user_version=0 legacy DB missing `visibility` still gets the
column added, then stamped). 41 passed / 0 failed (MSVC), build warning-free.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments