Repository navigation
fix: remove duplicate document indexes from SCHEMA constant (#492) - #493
Merged
Merged
Conversation
Root cause: v0.5.0 added hierarchical document indexes (idx_documents_path/parent/depth/sort) to the SCHEMA constant, which runs via execute_batch() BEFORE versioned migrations. For DBs upgrading from v0.4.x, the documents table already exists (skipped by IF NOT EXISTS) but lacks the hierarchy columns, so CREATE INDEX references non-existent columns and the entire init_schema() fails. The indexes already exist in migrate_v11_to_v12() with proper column-existence guards. Removing them from SCHEMA eliminates the duplication and ordering conflict. Also adds: - Store::from_conn() test helper for pre-seeded DB migration tests - Regression test: simulates v0.4.x DB (schema_version=11, documents table without hierarchy columns) and verifies migration v11→v12 succeeds with all columns and indexes present
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-cli · BYOK · MIT |
ajianaz
added a commit
that referenced
this pull request
Aug 13, 2026
…ex-order fix: remove duplicate document indexes from SCHEMA constant (#492)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #492 — v0.5.0 schema migration fails when upgrading from v0.4.x.
Root Cause
The v0.5.0 release added 4 hierarchical document indexes to the constant:
idx_documents_pathidx_documents_parentidx_documents_depthidx_documents_sortThese indexes reference columns added by migration v11→v12. However,
SCHEMAis executed viaexecute_batch()before versioned migrations run. For existing v0.4.x DBs:CREATE TABLE IF NOT EXISTS documents→ skipped (table already exists)CREATE INDEX IF NOT EXISTS idx_documents_path ON documents(path)→ FAILS (columnpathdoesn't exist)execute_batchis atomic → entire init_schema() failsThe indexes already exist in
migrate_v11_to_v12()with propercolumn_existsguards, so they were duplicated.Changes
store.rsSCHEMAconstantstore.rsStore::from_conn()test helperstore.rsRegression Test
test_migration_v11_to_v12_from_v04x_db:Store::from_conn()to trigger init + migrationTest Limitation
Local test environment lacks
libssl-dev(needed byortbuild-deps), so tests verified on CI only.