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:
@ -37,7 +37,7 @@ export class SqliteDatabase {
|
||||
}
|
||||
|
||||
/**
|
||||
* INSERT / UPDATE / DELETEを実行する
|
||||
* INSERT / UPDATE / DELETEを実行する(単一プリペアドステートメント)
|
||||
*/
|
||||
execute(sql: string, params?: SqlParams): ExecuteResult {
|
||||
const result = this.db.prepare(sql).run(params ?? {});
|
||||
@ -48,6 +48,14 @@ export class SqliteDatabase {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 複数ステートメントを含むSQLを一括実行する(Migration用・パラメータバインド不可)。
|
||||
* better-sqlite3の exec() を利用し、セミコロン区切りの複数文・コメントを処理する。
|
||||
*/
|
||||
exec(sql: string): void {
|
||||
this.db.exec(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* トランザクション内でコールバックを実行する
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user