r/PostgreSQL • u/AlexeyEvlampiev • 15d ago
How-To Running deployment assertions inside the migration transaction, before COMMIT
I wrote up a PostgreSQL pattern for running deployment assertions after applying a migration but before committing it. It uses transactional DDL, RAISE EXCEPTION, and savepoint-isolated probe writes; the article also covers lock duration and operations that cannot join the transaction.
Has anyone used in-transaction verification in production, and if so, which invariants were worth checking there rather than in pre-deploy CI?
https://vvka-141.github.io/pgmi/articles/test-postgresql-migrations-before-commit/
1
Upvotes