fix(ledger): post-migration schema verification for decisions table (GH-343)#345
Merged
fix(ledger): post-migration schema verification for decisions table (GH-343)#345
Conversation
…le (GH-343) If a migration partially failed (version bumped but ALTER TABLE didn't stick), subsequent opens would skip the migration, leaving the DB inconsistent. verify_decisions_schema() now runs after apply_schema() and repairs any missing columns by re-issuing the appropriate ALTER TABLE ADD COLUMN statements. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
verify_decisions_schema()that runs afterapply_schema()to detect and repair missing columns in thedecisionstablePRAGMA table_info(decisions)to compare actual columns against expected set (all 17 columns)ALTER TABLE ADD COLUMNwith correct defaultswarnwhen a column is detected missing and repairedProblem
If a migration partially fails (column not actually added but version still bumped), subsequent opens skip the migration entirely, leaving the DB in an inconsistent state — version says 10 but columns from V5/V10 may be missing.
Test plan
verify_decisions_schema_repairs_missing_columns— creates a DB at V10 with only base V2 columns, opens it, verifies all 17 expected columns are present after repaircargo fmt -p edda-ledger— cleancargo clippy -p edda-ledger -- -D warnings— cleancargo test -p edda-ledger— 151 tests passCloses #343
🤖 Generated with Claude Code