-
Notifications
You must be signed in to change notification settings - Fork 30
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
Backward migrations #57
Comments
Interesting idea! How would you change Stamina to support this? What would the code look like? |
In our deployment model rollback is a deploy of old version of application, so there is no way to add just one commit to codebase with migration. The idea is to define backward migration along with forward migration. When we want to replace version X of application and deploy version Y, then we have to store somewhere what version of each message is in application version X. Having that, in case of rollback we make backup of current database, migrate backup form newer to older version (using backward migrations). Then we can drop tables and restore migrated backup. We want to do this only for snapshots in order to minimalize number of messages. I haven't think yet about how to implement this, because I don't have confirmation if it has sense from your point of view. |
I think it would depend on the solution and how it impacts the usability of the main model more than anything else. If adding backwards migrations (i.e. an unusual corner case AFAIK) would make Stamina a lot harder to use, I'd vote to keep it out. If, on the other hand, it could be added in a way that makes sense and keeps the main use case as simple as it is now, I would be interested in merging it. I think the only way (I can see) to do this cleanly would be to keep the main DSL mostly untouched but somehow make sure every transformation is safely bidirectional so it can be applied backwards. And then You would have to separate the idea of the "currently supported" version from the migrations in some way. In other words: I don't really have an idea for how to do it but if you can come up with one, we would definitely be interested! |
I was reading this discussion and came with an idea similar to @psliwa's one but working in a slightly different way. Currently both I think it could be useful in few situations. Possible scenario could be:
what it can solve:
|
In general @kkafara idea looks IMHO ok, rolling upgrade looks promising. The only concern I have is that it moves complexity from eventual rollback (which is something that doesn't occur so often) to regular development and deployment process. So when you have more persisted types, developing become complicated - you need to prepare new RC with only new migrator and perform two deployments: old production version with new migrators and new production version. Maybe both solutions can be applied? |
Hello,
Are backward migrations possible in stamina? Using current api I wasn't able to figure out how to define backward migration.
The use case is rollback: when we deploy new version with schema version
V5
but then we decide to rollback whole application to version withV3
schema, we would like to migrate data fromV5
toV3
in the fly.Does it make sense? If it does I can try to prepare PR for that.
The text was updated successfully, but these errors were encountered: