Skip to main content

find_foreign_key_violations

Function find_foreign_key_violations 

Source
pub fn find_foreign_key_violations(
    conn: &Connection,
) -> Result<Vec<(String, i64)>, AppError>
Expand description

Every PRAGMA foreign_key_check row, as (child table, rowid).

Table-agnostic on purpose. The guard above knows about every child table in the schema — eleven of them reference memories, entities, relationships or memory_chunks — so a repair that knows about only one leaves the warning pointing at a command that cannot deliver, and goes stale the day a migration adds the twelfth. A rebuild-and-rename of entities orphans four tables at once, not just relationships, which is exactly how this state is produced.

A row reported here is unreachable by construction: with enforcement on, SQLite would have cascaded it away when its parent was deleted. Removing it destroys no reachable data.

§Errors

Returns Err when the pragma cannot be prepared or read.