Skip to content

fix(ledger): post-migration schema verification for decisions table (GH-343)#345

Merged
fagemx merged 1 commit intomainfrom
fix/GH-343-verify-decisions-schema
Mar 20, 2026
Merged

fix(ledger): post-migration schema verification for decisions table (GH-343)#345
fagemx merged 1 commit intomainfrom
fix/GH-343-verify-decisions-schema

Conversation

@fagemx
Copy link
Owner

@fagemx fagemx commented Mar 20, 2026

Summary

  • Adds verify_decisions_schema() that runs after apply_schema() to detect and repair missing columns in the decisions table
  • Uses PRAGMA table_info(decisions) to compare actual columns against expected set (all 17 columns)
  • For each missing column, re-issues the appropriate ALTER TABLE ADD COLUMN with correct defaults
  • Logs a warn when a column is detected missing and repaired

Problem

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

  • New test 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 repair
  • cargo fmt -p edda-ledger — clean
  • cargo clippy -p edda-ledger -- -D warnings — clean
  • cargo test -p edda-ledger — 151 tests pass

Closes #343

🤖 Generated with Claude Code

…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>
@fagemx fagemx merged commit ee71166 into main Mar 20, 2026
1 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(ledger): schema migration chain silently skips failed ALTER TABLE

1 participant