/** * @fileoverview Test database helpers — prevents "no such table" for migrated tables * @see SMI-2749 * @see SMI-4756 — async variant added to support WASM fallback in post-merge-verify * * Use createTestDatabase() instead of createDatabase(':memory:') whenever tests * need tables that only exist in migration files (e.g. skill_versions). * * WHY THIS EXISTS: * createDatabase(':memory:') calls initializeSchema(), which records SCHEMA_VERSION=5 * directly in schema_version WITHOUT running the intermediate migration SQLs. * runMigrations() then sees version=5 and skips all migrations — a no-op. * Tables defined only in migration SQL (not in SCHEMA_SQL) are never created. * Example: skill_versions is in MIGRATION_V5_SQL, not SCHEMA_SQL. * * createTestDatabase() iterates MIGRATIONS directly (no version gate) so every * migration's SQL runs unconditionally. New migrations added to MIGRATIONS are * automatically included — no change required here. * * SMI-4756: createTestDatabase is now async. It uses createDatabaseAsync() so the * sql.js WASM driver is used automatically when better-sqlite3 native bindings are * unavailable (e.g. in post-merge-verify CI where the native module is not rebuilt * for the container platform). Callers must await the result and use async beforeEach. */ import type { Database } from '../../src/db/database-interface.js'; export { closeDatabase } from '../../src/db/schema.js'; export type { Database } from '../../src/db/database-interface.js'; /** * Create an in-memory SQLite database with ALL schema + migrations applied. * * Safe to use for any test that needs migrated tables (e.g. skill_versions, * sync_config, sync_history). Forward-compatible: new migrations added to * MIGRATIONS are included automatically. * * SMI-4756: Returns a Promise so the sql.js WASM driver is used automatically * when better-sqlite3 native bindings are unavailable. Callers must await. * * @returns Promise resolving to a Database with full schema + all migrations applied */ export declare function createTestDatabase(): Promise; //# sourceMappingURL=database.d.ts.map