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:
@ -2,6 +2,7 @@ import os from 'node:os';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { SqliteDatabase } from '@/lib/db/sqlite';
|
||||
import { Migrator } from '@/lib/db/migrator';
|
||||
|
||||
let counter = 0;
|
||||
|
||||
@ -38,8 +39,6 @@ export function createTestDb(): SqliteDatabase {
|
||||
export function createMigratedTestDb(): SqliteDatabase {
|
||||
const db = createTestDb();
|
||||
const migrationsDir = path.join(process.cwd(), 'lib', 'db', 'migrations');
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const { Migrator } = require('@/lib/db/migrator');
|
||||
const migrator = new Migrator(db, migrationsDir);
|
||||
migrator.migrate();
|
||||
return db;
|
||||
|
||||
Reference in New Issue
Block a user