/** * Migration registry schema (SPEC_F §F.5.1). * Tables: migration_runs, migration_dirty_keys, migration_errors. */ import type Database from './driver.ts'; export declare const MIGRATION_SCHEMA = "\nCREATE TABLE IF NOT EXISTS migration_runs (\n run_id TEXT PRIMARY KEY,\n source_uri TEXT NOT NULL,\n started_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n status TEXT NOT NULL,\n\n scan_cursor TEXT NOT NULL DEFAULT \"0\",\n scan_count_hint INTEGER NOT NULL DEFAULT 1000,\n\n scanned_keys INTEGER NOT NULL DEFAULT 0,\n migrated_keys INTEGER NOT NULL DEFAULT 0,\n skipped_keys INTEGER NOT NULL DEFAULT 0,\n error_keys INTEGER NOT NULL DEFAULT 0,\n migrated_bytes INTEGER NOT NULL DEFAULT 0,\n\n dirty_keys_seen INTEGER NOT NULL DEFAULT 0,\n dirty_keys_applied INTEGER NOT NULL DEFAULT 0,\n dirty_keys_deleted INTEGER NOT NULL DEFAULT 0,\n\n last_error TEXT\n);\n\nCREATE TABLE IF NOT EXISTS migration_dirty_keys (\n run_id TEXT NOT NULL,\n key BLOB NOT NULL,\n\n first_seen_at INTEGER NOT NULL,\n last_seen_at INTEGER NOT NULL,\n events_count INTEGER NOT NULL DEFAULT 1,\n\n last_event TEXT,\n state TEXT NOT NULL DEFAULT \"dirty\",\n\n PRIMARY KEY (run_id, key)\n);\n\nCREATE INDEX IF NOT EXISTS migration_dirty_keys_state_idx\n ON migration_dirty_keys(run_id, state);\n\nCREATE INDEX IF NOT EXISTS migration_dirty_keys_last_seen_idx\n ON migration_dirty_keys(run_id, last_seen_at);\n\nCREATE TABLE IF NOT EXISTS migration_errors (\n run_id TEXT NOT NULL,\n at INTEGER NOT NULL,\n key BLOB,\n stage TEXT NOT NULL,\n message TEXT NOT NULL\n);\nCREATE INDEX IF NOT EXISTS migration_errors_at_idx ON migration_errors(run_id, at);\n"; /** * Apply migration registry schema to database. */ export declare function applyMigrationSchema(db: Database): void;