pub fn ensure_unique_pk_index(
conn: &Connection,
table: &str,
ts: &TableSchema,
) -> Result<(), ReplicaError>Expand description
Ensure the table has a UNIQUE index covering exactly the PK columns, which TableSource
requires for row-identity point lookups. Idempotent.
A rowid-alias INTEGER PRIMARY KEY is skipped: the rowid already enforces uniqueness and
SQLite point-looks-it-up natively (SEARCH … USING INTEGER PRIMARY KEY (rowid=?)), so a
synthetic index would be pure write amplification with no plan benefit — and TableSource
recognizes the rowid alias as a unique key without one. (Databases created by older versions
may still carry a now-unused rindle_replica_pk_* index; it is harmless and left in place.)
One implementation, shared with the apply plane
(crate::apply::ensure_unique_pk_index_for, design 309) — this is the
ColumnDef-shaped adapter for hosts on the embedded-engine seam.