Description
I've hand-written a pretty large baseline migration, and then started debugging it by creating a fresh database and running postgres-migrations
repeatedly. One problem I've run into is that crucial error details are lost inside this library, here:
postgres-migrations/src/run-migration.js
Lines 49 to 61 in 25e7379
Sometimes PostgreSQL spews out messages like syntax error at or near ")"
, in a file full of functions, triggers, constraints, arrays, etc. The only way to find the cause for an error like that is to know the position
, which is contained inside the err
returned from the driver.
The easiest solution would probably be to extend the error message with Position: ${err.position}
, but there may be some value is passing through the other fields too. An even better solution would be to print the problematic line and its surroundings, with the exact position pointed out with a ^
, but that's a lot of extra effort for a small QoL improvement, so that's just an idea for the future.