/**
 * Migration: 006 - FTS5 Reflection Notes Column
 * Description: Create new FTS5 table (memory_item_fts_new) with reflection_notes column for Zero-Downtime migration
 * Version: 6.0
 * Date: 2025-01-XX
 *
 * This migration implements Step 1 of the Zero-Downtime migration strategy:
 * - Creates memory_item_fts_new table with reflection_notes column
 * - Does NOT re-index existing data (handled in Step 2)
 * - Does NOT create triggers (handled in Step 3)
 * - Does NOT replace tables (handled in Step 4)
 *
 * See docs/architecture/zero-downtime-fts5-migration.md for full migration strategy.
 */
import type Database from 'better-sqlite3';
import type { Migration } from '../types.js';
/**
 * FTS5 Reflection Notes Migration (Step 1: New Table Creation)
 *
 * This migration:
 * 1. Creates memory_item_fts_new virtual table with reflection_notes column
 * 2. Validates table creation
 * 3. Does NOT re-index existing data (handled separately)
 * 4. Does NOT create triggers (handled separately)
 */
export declare class FTS5ReflectionNotesMigration implements Migration {
    version: string;
    name: string;
    description: string;
    /**
     * Load SQL file content
     */
    private loadSQLFile;
    /**
     * Execute SQL script
     * Removes transaction commands (BEGIN TRANSACTION, COMMIT) as MigrationRunner manages transactions
     */
    private executeSQL;
    /**
     * Check if virtual table exists
     */
    private virtualTableExists;
    /**
     * Validate before migration
     */
    validateBefore(db: Database.Database): Promise<void>;
    /**
     * Re-index existing data from memory_item to memory_item_fts_new
     *
     * This implements Step 2 of the Zero-Downtime migration strategy:
     * - Processes data in batches (1000 records per batch)
     * - Normalizes reflection_notes using normalizeReflectionNotes utility
     * - Commits each batch separately for performance and safety
     * - Logs progress every 10%
     */
    private reindexExistingData;
    /**
     * Create temporary dual triggers for synchronizing new writes during migration
     *
     * This implements Step 3 of the Zero-Downtime migration strategy:
     * - Creates temporary triggers that insert into memory_item_fts_new
     * - Existing triggers continue to insert into memory_item_fts
     * - Both tables are kept in sync during migration
     *
     * Duplicate Insert Prevention:
     * - FTS5 automatically handles duplicate rowid inserts (updates existing record)
     * - Triggers fire only once per INSERT/UPDATE/DELETE event, so duplicates are unlikely
     * - Transaction-level duplicate prevention is handled at application level
     *
     * Note: reflection_notes normalization is applied using normalize_reflection_notes function.
     */
    private createDualTriggers;
    /**
     * Drop temporary dual triggers
     * Used for rollback or cleanup
     */
    private dropDualTriggers;
    /**
     * Check if trigger exists
     */
    private triggerExists;
    /**
     * Register normalize_reflection_notes user-defined function
     * This function must be registered before triggers that use it
     *
     * Note: SQLite does not support dropping user-defined functions directly.
     * If the function already exists and is in use by active statements,
     * registering it again will fail with "unable to delete/modify user-function due to active statements".
     *
     * To avoid this, we check if the function is already registered and skip re-registration.
     */
    private functionRegistered;
    private registerNormalizeFunction;
    /**
     * Perform atomic table replacement
     *
     * This implements Step 4 of the Zero-Downtime migration strategy:
     * - Drops existing triggers
     * - Drops temporary dual triggers
     * - Drops existing FTS5 table
     * - Renames new table to original name
     * - Creates new triggers with reflection_notes support and normalization
     *
     * All operations are performed in a single transaction for atomicity.
     */
    private performAtomicTableReplacement;
    /**
     * Execute migration (Up)
     */
    up(db: Database.Database): Promise<void>;
    /**
     * Rollback migration (Down)
     */
    down(db: Database.Database): Promise<void>;
    /**
     * Validate after migration
     */
    validateAfter(db: Database.Database): Promise<void>;
}
//# sourceMappingURL=006-fts5-reflection-notes.d.ts.map