import type Database from 'better-sqlite3'; /** * Compute SHA-256 checksum of migration SQL content. */ export declare function computeChecksum(sql: string): string; /** * Get the current migration version from the database. * Returns 0 if no migrations have been applied. */ export declare function getCurrentVersion(db: Database.Database): number; /** * Verify schema integrity: all expected tables and indexes exist. * Returns an array of missing table/index names, or empty if all present. */ export declare function verifySchemaIntegrity(db: Database.Database): string[]; /** * Verify migration checksums. * By default (verifyAll=false), only checks the latest migration. * With verifyAll=true, checks all applied migrations. * * @throws MigrationChecksumMismatchError on mismatch (ERR-MIG-003) */ export declare function verifyChecksums(db: Database.Database, verifyAll?: boolean): void; /** * Run all pending migrations on the database. * Each migration is applied in a transaction. * After all migrations, a schema integrity check is performed. * Idempotent: if all migrations are already applied, no action is taken. * * @param db - Database connection * @param targetVersion - Optional target version (defaults to latest) * @throws MigrationError if a migration fails (ERR-MIG-001) * @throws MigrationIntegrityError if integrity check fails (ERR-MIG-002) */ export declare function runMigrations(db: Database.Database, targetVersion?: number): void; /** * Initialize the builtin graph schema (relation types + graph_schema metadata). * * Implements AD-0048: Two-pass FK-safe insertion strategy. * * Pass 1: Insert all relation types WITHOUT inverse_of (avoids FK violations * when the referenced inverse type row does not yet exist). * Pass 2: UPDATE each type's inverse_of to its final value. * * Both passes run within a single transaction with FK enforcement active. * * @requires PRAGMA foreign_keys = ON — caller must ensure FK enforcement is enabled * before invoking this function. */ export declare function initializeBuiltinSchema(db: Database.Database): void; /** * Initialize a fresh database with the full schema. * Also verifies the latest migration checksum on open (VR-006). * Builtin schema is initialized after migrations (FS-SS-008-0007-A). */ export declare function initializeSchema(db: Database.Database, verifyAll?: boolean, skipBuiltinSchema?: boolean): void; /** * Check if the database schema is up to date. */ export declare function isSchemaUpToDate(db: Database.Database): boolean; /** * Get list of pending migration versions. */ export declare function getPendingMigrations(db: Database.Database): number[]; //# sourceMappingURL=migration.d.ts.map