Skip to content

Give each database step its own number, so the app starts again - #23

Merged
Abe-Borg merged 1 commit into
mainfrom
claude/jolly-brahmagupta-4yw65w
Dec 1, 2026
Merged

Abe-Borg merged 1 commit into
mainfrom
claude/jolly-brahmagupta-4yw65w

Conversation

@Abe-Borg

@Abe-Borg Abe-Borg commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

What went wrong

#21 added 0010_trash.sql, and #22 added 0010_chosen_for_the_user.sql (and 0011_claude_months.sql). Both were merged, and nothing conflicted because the file names differ. Since then, every start fails with:

CodePull could not start — UNIQUE constraint failed: schema_migrations.version

Every unit test that opens a Store fails the same way, and CI on main (7fbafc5) is red on all three operating systems. The steps run in one transaction, so a failed start leaves the data folder as it was. Each attempt also rewrites app.db.bak-<n> with the same contents.

The fix

  • 0010_trash.sql keeps 10, because it reached main first.
  • 0010_chosen_for_the_user.sql → 0011_chosen_for_the_user.sql
  • 0011_claude_months.sql → 0012_claude_months.sql

No release contains any of these steps (0.3.0 ends at 0008), so installed copies are unaffected. A data folder written by main between the two merges (10 = trash) picks up 11 and 12 as normal.

Keeping it from happening again

  • migrationScripts in src/db/store.ts refuses two steps that share a number, before the database is opened. The error names both files, so a bad merge fails every test straight away with a clear message.
  • New tests in test/store.test.ts:
    • the shipped steps have unique numbers, and a folder with a shared number is refused without creating or backing up a database;
    • a data folder from before step 10 (the owner's case) upgrades through all three steps.
  • The two "earlier version" test folders now start at the new numbers.
  • CLAUDE.md, docs/architecture.md and decision 11 name the new numbers. CLAUDE.md now says that the branch merged second renumbers its steps first.

Checks

  • npm test: 239 passed
  • tsc (main and ui) and npm run format:check: clean
  • npm run build and xvfb-run -a npm run test:app: running when this was opened; results follow in a comment if anything fails.

https://claude.ai/code/session_01T34myw2b3182Wh95SF4i7u


Generated by Claude Code

Two branches each added migration 0010 (the trash, and the settings chosen
for the user) and both were merged. Every start then failed with "UNIQUE
constraint failed: schema_migrations.version", and so did every test that
opens a store. The migrations run in one transaction, so a failed start
changed nothing in the data folder.

The trash was merged first and keeps 0010. The settings step becomes 0011
and the month's spending 0012. No release holds any of them (0.3.0 ends at
0008).

Store now refuses two steps that share a number before it opens the
database, with a message naming both files, and a test checks the shipped
folder and a data folder from before all three.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T34myw2b3182Wh95SF4i7u
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T05:45:41.160684Z 27b08c8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Abe-Borg
Abe-Borg merged commit d2243cd into main Dec 1, 2026
1 of 4 checks passed
@Abe-Borg
Abe-Borg deleted the claude/jolly-brahmagupta-4yw65w branch December 1, 2026 05:50
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.

2 participants