/** * SQLite schema and migration DDL for the SQLite-authoritative sync storage layer. * * Implements the logical schema owned by this module. All identity constraints, * unique indexes, and foreign keys are fixed here. * * Table creation order is parent-first. Deletion order is child-first. */ /** * The outbox kernel owns the required-column contracts and the v5 probe * index for the durable delivery columns; the sheets-authority columns and * the remaining tables stay here. */ export { REQUIRED_V3_COLUMNS } from "@hikoutei/ikisaki"; export { syncSchemaV5IndexesDdl } from "@hikoutei/ikisaki"; /** Current durable schema version managed by the provider migration. */ export declare const CURRENT_SCHEMA_VERSION = 9; /** * Covering index for the keyset-paged cleanup binding scan * (`WHERE logical_sheet_id = ? AND row_binding_id > ? ORDER BY * row_binding_id LIMIT ?`). Without it the scan sorts every binding of the * sheet in a temp b-tree per page; with it each page is a bounded covering * index range scan. */ export declare const SCAN_INDEX_DDL = "\n CREATE INDEX IF NOT EXISTS row_binding_scan_idx\n ON row_binding(logical_sheet_id, row_binding_id);\n"; /** * Covering index for the entity-batched scan pages: the desired-state and * cleanup-canonical readers page whole entities in `entity_state` primary * key order, then fetch each entity's bindings here. Every lookup is an * index seek with no temp-b-tree sort (verified with EXPLAIN QUERY PLAN): * the entity page follows the `entity_state` PK, field fetches follow the * `entity_field_state` PK prefix, and this index serves the binding fetch * as a covering range scan. A flat cross-table keyset can never get such a * plan — the row-value predicate over joined tables forces SQLite to * materialize and sort the whole join per page — which is why the readers * page entities instead of flat rows. */ export declare const SCAN_ENTITY_INDEX_DDL = "\n CREATE INDEX IF NOT EXISTS row_binding_entity_idx\n ON row_binding(logical_sheet_id, entity_id, state, row_binding_id, anchor_reference);\n"; /** Observable result of bringing one SQLite database to the current schema. */ export interface SchemaMigrationResult { readonly fromVersion: number; readonly toVersion: number; /** Versions newly applied during this call; empty means already current. */ readonly appliedVersions: readonly number[]; } /** Connection settings required by every typed-sheets SQLite store. */ export declare const SQLITE_CONNECTION_PRAGMAS = "\n PRAGMA foreign_keys = ON;\n PRAGMA journal_mode = WAL;\n PRAGMA busy_timeout = 5000;\n"; /** Columns that must exist before a version-two-or-later marker is trusted. */ export declare const REQUIRED_V2_COLUMNS: Readonly>; /** Columns required before the durable uncertain-delivery marker is trusted. */ export declare const REQUIRED_V5_SCHEMA_COLUMNS: Readonly>; /** * Merges the outbox kernel's required columns with the sheets-authority * columns so the migration can verify both tables from one map. */ export declare const REQUIRED_V5_COLUMNS: Readonly>; /** Candidate-evidence columns added to sync_conflict by the v6 migration. */ export declare const REQUIRED_V6_COLUMNS: Readonly>; /** * Columns that must exist in the v7-cleaned quarantine table. The repair * columns (repair_state, repair_fields_json, candidate_payload_json) were * dead — never read by the repair executor — and are removed by the v7 * migration; only the surviving evidence columns are required. */ export declare const REQUIRED_V7_COLUMNS: Readonly>; /** Entity-stamped opaque dispatch bucket added to the outbox by the v9 migration. */ export declare const REQUIRED_V9_COLUMNS: Readonly>; /** * Columns and tables removed from the durable schema by the v7 cleanup * migration. Present in pre-v7 databases; verified absent at version 7. */ export declare const DROPPED_V7_TABLES: readonly string[]; export declare const DROPPED_V7_COLUMNS: Readonly>; /** Returns table DDL only, so migration transactions never change connection pragmas. */ export declare function syncSchemaTablesDdl(): string; /** * Creates indexes that depend on additive migration columns only after those * columns have been confirmed. This keeps a version-one upgrade ordered. */ export declare function syncSchemaIndexesDdl(): string; //# sourceMappingURL=schema.d.ts.map