Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mechanism to seed a new open-balena instance? #1420

Open
shaunco opened this issue Sep 4, 2023 · 2 comments
Open

Mechanism to seed a new open-balena instance? #1420

shaunco opened this issue Sep 4, 2023 · 2 comments

Comments

@shaunco
Copy link
Contributor

shaunco commented Sep 4, 2023

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:

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".

@shaunco
Copy link
Contributor Author

shaunco commented Oct 6, 2023

@thgreasi / @Page- - any thoughts on this?

@Page-
Copy link
Contributor

Page- commented Dec 18, 2023

Other than the options you've covered @shaunco the only things that come to mind are:

  • Use the SDK as I believe you can probably do those things using it
  • Edit /init.ts taking inspiration from the createSuperuser function
  • Add an "async migration" with finalize: 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants