Closed nicoburns closed 3 years ago
There are a couple of constructor options you can pass which might accomplish what you're looking for.
noSupervisor
will bypass maintenance and noScheduling
will bypass cron monitoring
I actually have this same code set up in up my app for similar purposes of migration-only bootstrapping.
async function init(options) {
const b = new PgBoss({ ...options, noSupervisor: true, noScheduling: true })
await b.start()
await b.stop()
}
Ah yes, thanks for your response. This is working fine for my use case :)
Hi there. I'm currently working on integrating pg-boss into our backend and I have a request.
I want to make use of pg-boss's automatic tracking of schema version, and it's ability to compute which migrations should be run. However, I don't want pg-boss to run these migrations every time it starts up because this could cause a single microservice with the upgraded version to inadvertently upgrade the schema for the pg-boss tables causing clients still on an older version to stop working.
This what I want to do is have a method in PgBoss that I can call with my database credentials at a time of my choosing that runs the migrations.
Contractor.start()
seems to be the method to do this. It seems that I can get at this method by callingPgBoss.start()
, which should work fine. But this also does a whole bunch of other stuff which I don't really need at "migration time" and seems like it could potentially cause issues (even if this is unlikely).I am therefore wondering if either:
migrate
function that takes a db connection (and a schema) and callsContractor.start()
could be exposed.Thanks for the generally great seeming library. Nico