Closed maxkorp closed 4 years ago
This is an annoying bug that’s because node-postgres turns multiple statements into a representation that Postgres executes as a single transaction. The solution currently is to only have one statement per migration for no-transaction mode. I don’t know how to reliably fix this without using a SQL parser to split statements apart, so it’s an open issue.
That's... amazing >.<
I can't find a way to send stuff as raw, either. Or disable the transaction. That's great. Perhaps I could wrap it all inside a do block with an exec
That might work?
Found this on 0.0.11, but confirmed to still be broken on 0.017. For reference, we're using the
maxkorp/postgis:11.4-2.5.2
docker image locally to dev against. @johnhaley81 swears he tried this at some point and it was working in our codebase, so there was some sort of regression, but we haven't updated migrate since we first brought in the version with this enabled, so possibly something with a node_module (more on that later).Specifically, we pasted the following (redacted) into current.sql, after selecting the whole file so we're sure it's at the beginning of the file.
Unfortunately we still get errors about alter type in a transaction
I've tried this both as part of
migrate commit
, where it runs the committed migrations (which all have transactions) first, as well asmigrate watch --once
, where no previous transactions have been established, in case it was hanging on to one still.Where it gets interesting:
The code in migrate ts that determines if there should be a transaction works correctly. Using the latest version for simplicity, https://github.com/graphile/migrate/blob/master/src/migration.ts#L197 correctly assigns false to
transaction
.https://github.com/graphile/migrate/blob/master/src/migration.ts#L202 (where it begins the transaction) never runs.
Once it tries to run however, it fails with the above error. I've tried stepping through the instrumentation with
node --inspect-brk
but couldn't find it starting a transaction anywhere, but it's clearly happening still.Note that a few weeks back, there was an update to node-postgres (
pg
) that contained at least one unrelated breaking change (with regards to erroring when there is a cert chain validation error, a good and valid change but a breaking change in a minor version bump none the less). Possibly something else changed there to cause this issue.