/**
 * Pre-Migration Backup
 *
 * Automatically creates a backup of a database file before schema migrations
 * are applied. This protects user data when Docker images are updated and
 * the new code runs forward-only migrations on existing databases.
 *
 * Backup naming: {name}.db.pre-migrate-v{oldVersion}
 * - Only created when the DB schema version < current SCHEMA_VERSION
 * - Skips backup for fresh databases (version 0) and already-current databases
 * - If a backup for the same version already exists, it is NOT overwritten
 *   (the first backup is the pristine pre-migration copy)
 * - Old backups are cleaned up: only the most recent N are kept (default 3)
 *
 * @module database/pre-migration-backup
 */
import type Database from 'better-sqlite3';
export interface BackupResult {
    /** Whether a backup was created */
    created: boolean;
    /** Path to the backup file (set even if already existed) */
    backupPath: string | null;
    /** Schema version of the database before migration */
    fromVersion: number;
    /** Target schema version */
    toVersion: number;
    /** Reason if backup was skipped */
    reason?: string;
}
/**
 * Create a pre-migration backup of a database file if a migration is needed.
 *
 * Must be called BEFORE migrateToLatest() and AFTER the db connection is open.
 * Checkpoints the WAL internally to ensure the .db file is consistent before copying.
 *
 * @param db - Open database connection (used for WAL checkpoint)
 * @param dbPath - Full path to the .db file
 * @param currentVersion - Current schema version in the database (from checkSchemaVersion)
 * @param targetVersion - Target schema version (SCHEMA_VERSION constant)
 * @returns BackupResult describing what happened
 */
export declare function createPreMigrationBackup(db: Database.Database, dbPath: string, currentVersion: number, targetVersion: number): BackupResult;
/**
 * Remove old pre-migration backups, keeping only the most recent `keep` count.
 * Sorted by version number extracted from filename (lowest version = oldest).
 */
export declare function cleanupOldBackups(dir: string, dbFileName: string, keep: number): void;
//# sourceMappingURL=pre-migration-backup.d.ts.map