|
|
|
|
|
by pasxizeis
396 days ago
|
|
A "Postgres lock diagnostics" tool for migrations. We've been bitten a few times, by seemingly innocent migrations that ended up acquiring locks we did not expect (yes, RTFM). So I thought: what if, when you opened the PR, you had a tool that actually executed your migrations, saw what locks they acquired (in runtime) and then reported it as a comment to your PR? This would provide you with yet another data point you could use to reason about whether your migration is safe to deploy or not. For example: ALTER TABLE users ADD COLUMN email TEXT:
acquired AccessExclusiveLock on relation `users`
It does this by opening a transaction, executing the statement, and observing the `pg_locks` view from _a different_ connection before the initial transaction is rolled bac (or committed, depending in the flags you passed). The idea is to be able to use it as a CLI, as a library or with a ready-made GitHub Action (which will take care of commenting in your PR).It's in early-stage and very much a PoC yet, but I think there's merit in the idea. https://github.com/agis/pglockanalyze P.S. Also, an excuse to learn Rust - so any feedback from Rust ppl more than welcome |
|
https://github.com/ankane/strong_migrations?tab=readme-ov-fi...
It's pretty popular, and has even been ported to other languages
https://github.com/Artur-Sulej/excellent_migrations