Summary
nullboiler has no migration version tracking, causing all migrations to run on every startup. Migration 004's ALTER TABLE ADD COLUMN statements fail on any database that was previously initialized, crashing the process immediately.
Root Cause
store.zig migrate() runs all 4 migration SQL files unconditionally on every startup
- Migration 004 contains
ALTER TABLE ADD COLUMN statements for columns that already exist after the first successful run
state_json is already defined in 001_init.sql's CREATE TABLE runs — so migration 004 fails even on a fresh DB
Crash Output
info(store): migration 0+1 applied
info(store): migration 0+2 applied
info(store): migration 0+3 applied
error(store): migration 004 failed (rc=1): duplicate column name: state_json
error: MigrationFailed
Fix (PR #3)
PR #3 adds PRAGMA user_version tracking to store.zig:
- Read version on startup, only run migrations with number > current version
- Set version after each successful migration
- Migration SQL files unchanged — version gate makes them naturally idempotent
Upgrade Note for Existing Databases
Databases created before this fix have user_version=0 despite being fully migrated. One-time manual bump required:
import sqlite3
db = sqlite3.connect('nullboiler.db')
db.execute('PRAGMA user_version = 4')
db.commit()
Summary
nullboiler has no migration version tracking, causing all migrations to run on every startup. Migration 004's
ALTER TABLE ADD COLUMNstatements fail on any database that was previously initialized, crashing the process immediately.Root Cause
store.zigmigrate()runs all 4 migration SQL files unconditionally on every startupALTER TABLE ADD COLUMNstatements for columns that already exist after the first successful runstate_jsonis already defined in001_init.sql'sCREATE TABLE runs— so migration 004 fails even on a fresh DBCrash Output
Fix (PR #3)
PR #3 adds
PRAGMA user_versiontracking tostore.zig:Upgrade Note for Existing Databases
Databases created before this fix have
user_version=0despite being fully migrated. One-time manual bump required: