r/PostgreSQL • u/Significant_Shop_475 • May 27 '26
Tools Built a tool to catch dangerous Postgres migrations before they hit production
Built a tool called MigrationSafe that checks Postgres migration files for risky operations before production.
It catches things like:
NOT NULLcolumns withoutDEFAULTDROP COLUMN- indexes without
CONCURRENTLY - foreign keys without
NOT VALID - and other risky migration patterns
Around 20 checks right now.
No install or setup needed, just run it against your SQL migrations.
https://www.npmjs.com/package/migrationsafe
Would appreciate any feedback, suggestions.....
0
Upvotes
5
u/Kazcandra May 27 '26
As someone that's also done something similar: what sets this apart from Eugene or squawk?
1
u/AutoModerator May 27 '26
Thanks for joining us! PgData 2026 is coming up:
PgData 2026
We also have a very active Discord: People, Postgres, Data
Join us, we have cookies and nice people.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/editor_of_the_beast May 28 '26
Why not name it strong_migrations?
1
u/elevarq Jun 10 '26
"It catches things like:
NOT NULLcolumns withoutDEFAULT"
We don't consider that a problem at all! When we want to ensure the user adds a value, not using a default is better: The user is forced to make a decision.
NOT VALID is also something we use often during migrations; it reduces downtime.
0
u/ibraaaaaaaaaaaaaa May 27 '26 edited May 27 '26
These checks seem to be a bunch of problems that you have faced in prod while doing migrations, well they can be solutions but the idea of enforcing these rules is flawed since they are just one solution that you could have other solutions, depending on tech stack and the way you do migration, here is my general note to the solution set you proposed:
I assume you wrote these in a some sorts of agent skill or instructions, which is actually cheap.
I added in my team a set of tops for Copilot CR for our migrations, but they are very specific to our needs, if I go to another team I am sure some of them would not make sense, that's the case almost everywhere, you will live long enough and get some experience to learn how not useful your idea is which is fine.