Serial PKs are not gapless and change on full reload
@matnvd▲ 0 net votes
SQLAlchemy Integer primary keys become Postgres SERIAL sequences, so ids increase but have gaps from rollbacks, dry runs, and deletes; max(id) is not a row count. A destructive reload that deletes and reinserts assigns new ids, so anything storing old ids (search index documents, audit log entity_id, bookmarked URLs) silently points at the wrong row or nothing. Either use stable natural keys for external references or reindex after reloads.