Make migrations safe to run twice

trailhead-api · Claude · branch chore/migrations · claude-opus-5 · cwd /home/user/code/trailhead-api · id 1053f779-5696-9f65-2fef-ebc0609dce2a · 2026-09-06 16:29 · 2 msgs · 6 tools · 1 min read · updated yesterday

A partially applied migration left the schema unrunnable; each step is now idempotent.

tools: Read, Edit, Bash
← trailhead-api Download .md
cd /home/user/code/trailhead-api && claude --resume 1053f779-5696-9f65-2fef-ebc0609dce2aResume works while the transcript is within Claude Code's retention window (~30 days).
Tool calls
Edit Edit: 7 calls (50.0%) 7 Read Read: 4 calls (28.6%) 4 Bash Bash: 3 calls (21.4%) 3
Token usage27.5K total
Input23.3K
Cache creation0
Cache read0
Output4.2K
Cache hit ratio0%· cold cache

A partially applied migration left the schema unrunnable; each step is now idempotent.

Conversation

Turn 1 — User

A migration failed halfway and now I cannot run it again.

Turn 2 — Assistant

Each step now checks its own precondition, so re-running skips what already applied rather than failing on a duplicate column. The runner records each completed step separately instead of marking the whole migration done at the end.

Added a test that interrupts a migration mid-way and re-runs it to completion.

Turn 3 — User

Does that cover a rollback?

Turn 4 — Assistant

No — this only makes forward runs repeatable. Rollback would need a down step per migration, which is a bigger change than the failure warranted.

Subjects

  • [[SQLite]]
  • [[REST API]]
  • [[pytest]]

Keyboard shortcuts

⌘K / Ctrl+KOpen command palette
/Focus search
g hGo to home
g pGo to projects
g sGo to sessions
j / kNext / prev row (tables)
?Show this help
EscClose dialogs

Structured queries

Mix key:value filters with free text in the palette:

type:sessionOnly session pages
project:llm-wikiFilter by project name (substring)
model:claudeFilter by model name (substring)
date:>2026-03-01Sessions after a date
date:<2026-04-01Sessions before a date
tags:rustPages mentioning a tag/topic
sort:dateSort results by date (newest first)

Example: type:session project:llm-wiki date:>2026-04 sort:date