graphile / migrate

Opinionated SQL-powered productive roll-forward migration tool for PostgreSQL.
MIT License
751 stars 58 forks source link

Query logging #181

Open tonyxiao opened 1 year ago

tonyxiao commented 1 year ago

Right now if there is an error it is really hard to track down which specific line caused the sql error (even something as basic as syntax). Would love to have logging for every statement that is executed and highlight for the problematic statements.

benjie commented 1 year ago

Graphile Migrate reads the file on the disk and then issues it to the database, it does not parse it and split it into individual statements (doing so is more complex than you might think thanks to the $<blah>$ string delimiters that Postgres uses). If the error comes back with details, we do try and tie those back to the relevant line in the source (see https://github.com/graphile/migrate/blob/main/src/instrumentation.ts ) but we can only do that when there's enough data.

Further, we don't currently support this well when you're using a current/ folder rather than a current.sql file - we effectively turn the current/ folder into a single SQL string and then locate the error in that - we don't currently map it back to the separate files.