/**
 * Unified migration manager for SQLite databases.
 *
 * Consolidates duplicated reconciliation, bootstrap, retry, and column-safety
 * logic that was previously copy-pasted between sqlite.ts (tasks.db) and
 * brain-sqlite.ts (brain.db). Both modules now delegate to these shared functions.
 *
 * @task T132
 * @see https://github.com/anthropics/cleo/issues/82
 * @see https://github.com/anthropics/cleo/issues/63
 * @see https://github.com/anthropics/cleo/issues/65
 */
import type { DatabaseSync } from 'node:sqlite';
import type { NodeSQLiteDatabase } from 'drizzle-orm/node-sqlite';
/** Required column definition for ensureColumns(). */
export interface RequiredColumn {
    name: string;
    /** ALTER TABLE ADD COLUMN DDL suffix (e.g., 'text', 'integer DEFAULT 0'). */
    ddl: string;
}
/**
 * Check whether a table exists in a SQLite database.
 */
export declare function tableExists(nativeDb: DatabaseSync, tableName: string): boolean;
/**
 * Check if an error is a SQLite BUSY error (database locked by another process).
 * node:sqlite throws native Error with message containing the SQLite error code.
 * @task T5185
 */
export declare function isSqliteBusy(err: unknown): boolean;
/**
 * Create a pre-migration safety backup of the database file.
 *
 * Only creates the backup once (idempotent). Non-fatal on failure.
 */
export declare function createSafetyBackup(dbPath: string): void;
/**
 * Bootstrap and reconcile the Drizzle migration journal.
 *
 * Handles three scenarios:
 * 1. Tables exist but no __drizzle_migrations — bootstrap baseline as applied
 * 2. Journal has orphaned hashes (from older CLEO version) — clear and re-mark all as applied
 * 3. Journal is healthy — no-op
 *
 * @param nativeDb - Native SQLite database handle
 * @param migrationsFolder - Path to the drizzle migrations folder
 * @param existenceTable - A table name used to detect if the DB has data (e.g., 'tasks' or 'brain_decisions')
 * @param logSubsystem - Logger subsystem name for reconciliation warnings
 */
export declare function reconcileJournal(nativeDb: DatabaseSync, migrationsFolder: string, existenceTable: string, logSubsystem: string): void;
/**
 * Run Drizzle migrations with SQLITE_BUSY retry and exponential backoff.
 *
 * @param db - Drizzle database instance
 * @param migrationsFolder - Path to the drizzle migrations folder
 */
export declare function migrateWithRetry(db: NodeSQLiteDatabase<any>, migrationsFolder: string): void;
/**
 * Ensure all required columns exist on a table.
 *
 * Uses PRAGMA table_info to inspect the schema and adds any missing columns
 * via ALTER TABLE ADD COLUMN. Safety net for databases where Drizzle migrations
 * could not run due to journal corruption or version skew.
 *
 * @param nativeDb - Native SQLite database handle
 * @param tableName - Table to check (e.g., 'tasks')
 * @param requiredColumns - Columns that must exist
 * @param logSubsystem - Logger subsystem name
 */
export declare function ensureColumns(nativeDb: DatabaseSync, tableName: string, requiredColumns: RequiredColumn[], logSubsystem: string): void;
//# sourceMappingURL=migration-manager.d.ts.map