Repository navigation
SQLite DDL migration runner (pre-launch requirement) - #1622
Conversation
Replace CREATE TABLE IF NOT EXISTS + ad-hoc idempotent-check migrations (migrate_embedding_origin) with a PRAGMA user_version-tracked runner. Existing databases now get pending migrations applied in order on startup instead of silently missing new columns/indexes. Current schema is canonicalized as migration 1 (frozen baseline); the embedding.origin column becomes migration 2. Connection-level PRAGMAs (foreign_keys, synchronous, busy_timeout) are set separately from migrations since SQLite forbids changing synchronous inside a transaction and they're per-connection state, not persisted schema. Co-Authored-By: Claude <[email protected]>
Databases from before this migration runner existed may already have embedding.origin (added by the old ad-hoc migrate_embedding_origin check) while user_version is still 0. Discovered by manually running the daemon against a copy of a real dev database: migration 2's ALTER TABLE crashed with "duplicate column name: origin". Guard with a table_info check before altering, matching the old code's behavior, and add a regression test for this exact upgrade path. Co-Authored-By: Claude <[email protected]>
Code Review SummaryReview Type: Initial Review (PR #1622, no prior reviews found) This PR replaces the old Requirements Check (issue #1320)
All acceptance criteria are met. I ran Verification of the specific risk areas called out(a) Connection-level PRAGMAs pulled out of the migration transaction — correct and safe. (b) (c) Atomicity — correct. Each migration runs in its own (d) HIGHEST RISK — migration 1 baseline fidelity: verified exact match. I diffed
No discrepancy found. This is the correct, careful outcome for the highest-risk item in the PR. (e) Test coverage gaps — real gaps exist, though none rise to Critical:
(f) Doc accuracy — good, appropriately discoverable. (g) (h) Deleted FindingsCritical IssuesNone found. Suggested Improvements
Nitpicks
Overall RecommendationAPPROVE The core deliverable — a versioned, transactional migration runner replacing the ad-hoc |
malibio
left a comment
There was a problem hiding this comment.
Review posted — see comment above for full report. Recommendation: APPROVE (self-approval blocked by GitHub; author and reviewer account are the same).
- pre_runner_database_with_origin_already_applied_upgrades_without_error now inserts a row before the simulated legacy ALTER and asserts its origin default plus rebuilt index shape, restoring the coverage the deleted test_migrate_embedding_origin_upgrades_legacy_db had. - New every_version_up_to_latest_has_a_defined_migration test: catches a LATEST_VERSION bump without a matching apply_migration arm before it panics against a real user database. - Documented why naive `;`-splitting is safe for BASELINE_SQL. Skipped (not blocking, judged disproportionate to the PR's scope): mid-batch failure/recovery test (the atomicity guarantee is structural, from SQLite's own transaction semantics, not runner logic worth re-testing), concurrent SqliteStore::new() race test (same busy_timeout mechanism already covered by test_concurrent_writers_retry_instead_of_erroring_on_busy), and removing the dead migration_name "unknown" arm (harmless, unreachable defensive code). Co-Authored-By: Claude <[email protected]>
Address Review SummaryAddressed 2 of the 3 suggested improvements from the review; skipped 1 nitpick as not worth the churn. ✅ Addressed
⏭️ Skipped
Full test suite (976 lib tests, all Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: All changes are additive test coverage plus one doc comment — no logic changes to the migration runner itself. The original review's APPROVE recommendation stands. |
Closes #1320