-
Notifications
You must be signed in to change notification settings - Fork 270
Initialization Tasks (e.g. creating database / seeding data) #2443
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
Comments
Wasm itself already allows for this kind of initialization but there is still some missing toolchain support, i.e. I'm not sure if there is any way to run arbitrary init code in Rust. |
There is a fundamental difference between initialization code that should be executed at "deployment" time (i.e. executed once when you "start" the application) vs. code that should be executed on every request. Which one are you talking about here? |
cf. #604 |
That's a good point. I was mainly thinking about database initialization / seeding here. Obviously, initialization code must be non-disruptive to work seamlessly when invoked as part of every application start. I don't expect the Wouldn't it be possible to invoke the Provisioning a database server with necessary configuration is something that I would consider as "out of scope" because that's deployment / infra related. |
Developers can use the
--sqlite
flag as part ofspin up
and provide SQL commands to perform common tasks like executing DDL and/or DML before the actual Spin App bootstraps. Although this is great and useful for some situations, there are currently limitations:default
databaseFacing those limitations results in developers coming up with different patterns, layouts, scripts, or make targets to bootstrap databases before running their Spin App. I think we could improve Spin here and make it more holistic to provide a general purpose initialization stage.
From DX point of view I would love to have a unified experience to perform initialization logic. Although I had different potential solutions in my mind, I wanna share my personal favorite approach here:
Wouldn't it be possible to provide an additional macro and let developers "code" their initialization logic? I'm thinking about something like shown below. 👇🏻
This would allow developers to use
variables
, andenvironment variables
configured in theirspin.toml
and to run initialization logic - like database seeding, no matter which DBMS they use.The text was updated successfully, but these errors were encountered: