Commit Graph

3 Commits

Author SHA1 Message Date
93f5d63f26 refactor: dedupe INSERT SQL and DDL exec in migrate.ts
All checks were successful
ci / test (pull_request) Successful in 12s
- 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).
2026-05-12 02:24:33 -07:00
a4c994ca9a feat: add runMigrateCli wrapper at sub-path './cli'
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.
2026-05-12 02:16:21 -07:00
d2dfa5f61b feat: add migration runner with genesisProbeTable param
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').
2026-05-12 02:16:16 -07:00