feat(m2): DB foundation tests + multi-statement migration fix

- Add SqliteDatabase.exec() using better-sqlite3 exec() so the migrator
  can run multi-statement SQL files (prepare() rejected 001_initial.sql)
- Migrator now uses exec() for migration file content
- Fix tests/helpers/db.ts: replace CJS require() with ESM import
- Add unit tests for SqliteDatabase (query/get/execute/transaction/exec,
  WAL & foreign_keys pragmas) and Migrator (ordering, idempotency,
  rollback, real 001_initial.sql applies)
- Restore .gitignore steering exclusion; remove stale steering files
This commit is contained in:
Ken Yasue
2026-06-25 00:21:26 +02:00
parent 07c7d424e5
commit d7c4cd5e58
13 changed files with 451 additions and 462 deletions

View File

@ -37,7 +37,7 @@ export class Migrator {
const sql = fs.readFileSync(fullPath, 'utf-8');
this.db.transaction(() => {
this.db.execute(sql);
this.db.exec(sql);
this.db.execute(
`INSERT INTO schema_migrations (filename, applied_at) VALUES (@filename, @appliedAt)`,
{ filename: file, appliedAt: new Date().toISOString() }