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

Embed migrations into compiled executable #351

Open
aqc-carlodri opened this issue Oct 4, 2024 · 2 comments
Open

Embed migrations into compiled executable #351

aqc-carlodri opened this issue Oct 4, 2024 · 2 comments

Comments

@aqc-carlodri
Copy link

In order to provide atomic updates of DB schemas + applications (preventing out-of-sync db/app updates), it would be very nice to have a feature to embed the migrations into the built executable.

Something along the lines of https://docs.rs/sqlx/latest/sqlx/macro.migrate.html.

I've seen several discussions and requests on this on Discord, but I didn't fully understand what is the roadmap on this.

Thanks!

@scotttrinh
Copy link

Shipping the migrations does not mean updates to the database schema are "atomic". The database and your application are still distributed, so without some kind of locking mechanism to synchronize, there will always be a time where one or the other is ahead. Moving the migration data itself closer to the application doesn't solve for that. The typical advice is to be careful when migrating that you're always backwards compatible at each step, so that you can smoothly upgrade the application and schema step-wise without any downtime. Sometimes that's not possible and you need to go into a maintenance period where the application needs to be taken offline when the migration is happening to avoid data corruption or runtime issues.

What bundling migrations does do is simplify some setups where getting the migration data in place to run migrations is made easier by bundling it with the application. However, with EdgeDB, since migrations typically happen via the CLI (as opposed to sqlx where you might use the Migrator struct in your app code) I don't think this solves anything for EdgeDB-specific use cases. If we had first-class support for migrating from your application code, I think this bundling pattern makes sense to have.

@aqc-carlodri
Copy link
Author

Hi Scott, thanks for the feedback. We actually have a fleet of machines where we would like each machine to have an instance of EdgeDB and an application deployed together. That's why I was asking for the "atomic" updates via bundling, so when I update the app, the DB update happens seamlessly. Do you have any recommendation for this flow/architecture?

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