/** * SMI-577: SQLite Database Schema with FTS5 * * Implements the core database schema for Skillsmith including: * - Skills table with full metadata * - FTS5 virtual table for full-text search * - Sources, Categories, and Cache tables * - WAL mode for performance * - Indexes for common query patterns * * SQL constants live in schema-sql.ts (SMI-3910) to avoid circular imports * with migration-runner.ts. This file re-exports them for backward compat. */ import type { Database } from './database-interface.js'; export { SCHEMA_SQL, FTS5_MIGRATION_SQL } from './schema-sql.js'; export { MIGRATIONS, getSchemaVersion, runMigrations, runMigrationsSafe, } from './migration-runner.js'; export type { Migration } from './migration-runner.js'; export type DatabaseType = Database; export declare const SCHEMA_VERSION = 18; /** * Initialize the database with the complete schema. * * SCHEMA_SQL only contains the v1 base tables; subsequent versions (skill_versions, * skill_advisories, etc.) are added by migrations. SMI-4486: previously this * recorded SCHEMA_VERSION (=current) directly, which caused runMigrations to * see the DB as already-current and skip every migration — leaving fresh DBs * stuck at v1 schema. Now we mark v1 (idempotent via OR IGNORE) and run * migrations to reach the current version. */ export declare function initializeSchema(db: DatabaseType): void; /** @deprecated Use createDatabaseAsync() — requires better-sqlite3 native module. */ export declare function createDatabase(path?: string): DatabaseType; /** * SMI-974: Open an existing database and run pending migrations. * @deprecated Use openDatabaseAsync() for cross-platform WASM support. */ export declare function openDatabase(path: string): DatabaseType; /** * Close the database connection safely. * * SMI-4640: Tolerate `undefined` so a failed `beforeEach` (e.g. native-module * load error in `createTestDatabase`) is reported as the original error instead * of being shadowed by a `Cannot read properties of undefined (reading 'close')` * cascade in `afterEach`. The underlying create-side error already carries the * actionable diagnostic (see `createDatabaseSync`). */ export declare function closeDatabase(db: DatabaseType | undefined | null): void; /** * Create a new database connection asynchronously with WASM fallback * This initializes the full schema - use openDatabaseAsync for existing databases * * @param path - Path to database file, or ':memory:' for in-memory * @returns Promise resolving to initialized database * @throws Error if database creation fails (e.g., invalid path, permission denied) * @throws Error if WASM module fails to load when native SQLite is unavailable */ export declare function createDatabaseAsync(path?: string): Promise; /** * Open an existing database asynchronously with WASM fallback * Runs any pending migrations * * @param path - Path to existing database file * @returns Promise resolving to database with migrations applied * @throws Error if file does not exist (SQLITE_CANTOPEN) * @throws Error if WASM module fails to load when native SQLite is unavailable */ export declare function openDatabaseAsync(path: string): Promise; //# sourceMappingURL=schema.d.ts.map