Developer builds Postgres migration linter that simulates schema state instead of scanning text
A developer has released safe-migrate, an open-source Postgres migration linter that simulates schema changes in memory rather than pattern-matching SQL text line by line. Unlike conventional linters that flag individual risky keywords, safe-migrate parses each statement into a typed AST node, applies it as a mutation to an evolving in-memory schema, and then evaluates rules against the updated state. This approach allows the tool to correctly resolve renamed tables, rewritten foreign keys, and other cross-statement dependencies that text-based scanners cannot track. Each finding is assigned one of four verdicts — HALT, CAUTIOUS, SAFE WITH RISK, or SAFE — based on the full context the simulator has accumulated up to that point. Key engineering challenges included handling ambiguous AST nodes in the squawk_syntax parser and correctly managing Postgres's case-sensitivity rules for quoted versus unquoted identifiers.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in