- Extract INSERT_MIGRATION_SQL constant; was repeated three times.
- Hoist db.exec(SCHEMA_MIGRATIONS_DDL) above the genesis-stamp branch
so it is no longer duplicated in both arms of the if/else.
- Prepare insertRow once and reuse it for both genesis-stamping and
the per-file insert in the apply loop.
- Simplify existence probe in stampMigration to SELECT 1 and drop the
misleading MigrationRow cast (only existence was checked).
Extracts the union of authd's three CLI scripts (db-migrate.ts,
db-status.ts, db-stamp.ts) into one wrapper. Consumers wire a ~5-line shim
that injects their own openDb / migrationsDir / config-loading logic. The
wrapper returns an exit code rather than calling process.exit, which keeps
it testable via PassThrough stream capture.
Forward-only SQLite migration runner lifted from authd (src/db/migrate.ts,
PR #14 / merge ced21ab) and parameterized for cross-project use. The single
deliberate API change vs. authd's source: the previously-hardcoded
GENESIS_PROBE_TABLE = 'users' is now an ApplyOptions.genesisProbeTable?: string
option (default 'users').