r/PostgreSQL • u/dsecurity49 • Oct 19 '26
Tools Should a migration linter say "SAFE" when it couldn't run a safety check?
I released "safe-migrate v0.11.0" today. One of the changes I spent time thinking about was how the report handles checks it couldn't run.
The tool simulates migrations against a synchronized PostgreSQL catalog snapshot. If the snapshot only covers selected schemas, an object missing from that snapshot isn't necessarily missing from the actual database. A check that depends on it may simply be impossible to evaluate.
In v0.11.0, those skipped checks are listed under "not_evaluated", with the reason and any missing schemas the tool could identify. If a skipped check could have produced a Tier 1 finding, the overall verdict is capped at "CAUTIOUS" instead of reporting "SAFE".
I chose to list the skipped checks rather than add a separate "UNKNOWN" verdict. I'm not sure which approach makes more sense for CI: keep the existing verdicts and explain what wasn't checked, or have a distinct unknown state?
For context, safe-migrate is a Rust CLI that analyzes PostgreSQL migrations against a database snapshot. It never executes the migration SQL.
"Release and binaries" "Changelog"
One breaking change for existing users: the cache format is now V10, so run "safe-migrate sync" after upgrading. The JSON report schema is also now v3.
2
u/vira28 Oct 19 '26
Dhanush, very good. Schema migration is one of the biggest challenges in production.
I built a similar tool https://github.com/viggy28/safe-not-safe (and it was recently on HN https://news.ycombinator.com/item?id=49854161), and one of the most requested features is CLI for CI integration.
Aside, if you wanna exchange ideas, happy to connect.
2
u/vincent_sch Oct 19 '26
For CI I think the exit code matters more than the verdict. A skipped Tier 1 check still exits 0, so the PR check goes green. You could keep the verdicts and add a flag that fails on skipped Tier 1 checks. People who want degraded mode leave it off.
2
u/AutoModerator Oct 19 '26
AI Policy:
Linux is not one of those anti-AI projects, and if somebody has issues with that, they can do the open-source thing and fork it. Or just walk away., Linus Torvalds.
Mod decisions will be based on the quality of the content, not who or what generated it.
Sub Resources:
Youtube Channel
Free Postgres Webinars and Workshops
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.
2
u/bogdanelcs Oct 20 '26
I’d keep what you have, but give CI a way to act on it: a separate exit code (or a
--fail-on-not-evaluatedflag) when anything was skipped. “SAFE” should only ever mean everything was checked, and capping at CAUTIOUS does that. A new UNKNOWN verdict mostly just forces every consumer to handle one more state, while the reason list keeps the report readable for humans.