fix: delete rows the county has superseded #5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/reconcile-superseded-rows"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The county re-records amended deeds — a misspelled name, the wrong buyer —
under a new book/page. Because book/page is part of the row key, the
correction arrives as a new row rather than an update, and the loaders only
ever INSERT OR REPLACE, so the superseded version was kept forever. Polk
currently has 145 such rows: users see sales that never happened (parcel
32001167000000 shows the same 2026-03-13 sale to both ROBERSTON and
ROBERTSON), and the inflated sale counts would raise watchlist notifications
for what are really corrections.
Treats the CSVs as the county's current state and deletes what is no longer
in them: SQLite is reconciled against the CSVs, then PostgreSQL against
SQLite. Converging the two copies also lets the existing row-count check
skip unchanged tables again, which is most of the nightly runtime.
Both passes refuse to delete more than 1% of a table (minimum 100 rows), and
treat an empty or unreadable source as a failed download rather than an
instruction to delete everything. ingest_log is deliberately not reconciled:
it is our own history, not the county's, and the staging copy legitimately
lacks rows PostgreSQL has.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com