Rindle docs and package mapSkip to main content

foreign_key_check

Function foreign_key_check 

pub fn foreign_key_check(
    conn: &Connection,
    max_rows: usize,
) -> Result<ForeignKeyAudit, ReplicaError>
Expand description

Walk every declared foreign key and report violating rows — the opt-in audit.

Independent of the connection’s ForeignKeys posture: PRAGMA foreign_key_check reports what is, not what SQLite would have refused, so this is exactly the tool for a replica that applies with enforcement off and wants proof rather than enforcement. It is a full scan of the referencing tables, so it is a deliberate operation (an operator command, a soak assertion, a post-restore gate), never a per-commit step.

Stops after max_rows violations, reporting ForeignKeyAudit::truncated; pass FOREIGN_KEY_AUDIT_ROW_CAP unless you have a reason not to. 0 means no cap.