Open shaunco opened 10 months ago
@thgreasi / @Page- - any thoughts on this?
Other than the options you've covered @shaunco the only things that come to mind are:
/init.ts
taking inspiration from the createSuperuser
functionfinalize: false
and use asyncFn: (tx: Tx, options: { batchSize: number }, sbvrUtils: SbvrUtils) => Resolvable<number>
to run js code as a migration that is still in-progress, you'd also need to handle ensuring it only runs once but as you should be able to do it in a single transaction you'll be able to create a record/check if it's previously been created and rely on transaction mechanisms to roll it back if necessary
Is there a proper mechanism for seeding a new open-balena instance with orgs, users, api-keys, fleets, and fleet-wide config/env variables? For our local machine test environment we'd like to always seed open-balena with the exact same details, and for dev/prod environments we'd like to automate as much as possible (rather than having human driven run-book actions).
Things I've tried:
customServerCode
entry (also injected via a volume mount in docker-compose)setup
functions are called and looking through https://github.com/balena-io/open-balena-api/blob/master/init.ts I'm still not really clearpostInit
test via docker-compose volume mount that does the initialization ... but, again, feels dirty/ping
to returnOK
and then makes a bunch ofcurl
calls to localhost to set things up?Really what I'm looking for is something like migrations that is guaranteed to run once on any new API cluster (uninitialized DB)... and none of the above seem like "the right way".