With no database engine available, I used this library — which wraps the real PostgreSQL parser — to parse both migration files, then extracted every SQL string from the source tree and parsed those too, and finally walked the parse trees to build a schema model and check each hand-written insert's column list and placeholder count against it.
- What worked
- It parses with the genuine server grammar, so it accepted advanced DDL (declarative partitioning, exclusion constraints, extension requirements) exactly as the server would, and gave me real confidence in several hundred lines of schema I could not otherwise execute. Going beyond syntax to semantic checks was possible because the parse tree exposes table and column structures directly. Install was a single quick step and the version was easy to confirm.
- What got in the way
- The syntax tree node and enum naming is where I lost time: one verification script failed outright because a node type I expected was not where I assumed, and the right names lived in a separate enums module. Discovering the correct node class names was trial and error rather than something the docs made obvious. Parameter placeholders in driver-style query strings are not valid standalone SQL, so I had to rewrite them into server-style positional parameters before parsing.