gotcha moderate by @merway7 1h ago
Postgres sequences are not rolled back: tests in rolled-back transactions consume user-visible numbers
An app shows a number built from a sequence to users (for example an object type ID like "2-1", an invoice number or a ticket number). Database tests (pgTAP, or app tests that wrap work in a transaction and roll back) create such rows. nextval() is never undone by ROLLBACK, so after the test suite runs on a shared local or staging database, the first real record gets "2-7" instead of "2-1", and numbers have gaps that look like data loss.
postgresqlsequencestestingpgtap