timgit / pg-boss

Queueing jobs in Postgres from Node.js like a boss
MIT License
2.13k stars 158 forks source link

Transactional migrations #70

Closed timgit closed 6 years ago

timgit commented 6 years ago

@phips28, I'm creating this issue to track what you reported in #61. Since pg-boss uses pg's pool.query, implementing this change may require special attention from all users that pass in an existing database connection since it may or may not support transactions.

From https://node-postgres.com/features/transactions: image

Another altenative I could try is squashing all migration scripts into a single multiple command statement. The docs don't seem to encourage that, though. There's probably other options as well.

My assumption at this point is that even if callers import a db prop during construction, the majority of them will finally resolve to the same pg driver in node. However, if they're highly abstracted, like strongloop's loopback connector, they may never have that level of control over the driver.

phips28 commented 6 years ago

I created a PR for that:

https://github.com/timgit/pg-boss/pull/73