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

Rollback support #2

Open
jammm opened this issue May 31, 2017 · 1 comment
Open

Rollback support #2

jammm opened this issue May 31, 2017 · 1 comment

Comments

@jammm
Copy link

jammm commented May 31, 2017

It would be great to be able to rollback to previous migration instead of having to forcefully drop the keyspace. How difficult would it be to implement something like this?

@jammm jammm changed the title Rollbacks support Rollback support May 31, 2017
@danielkza
Copy link
Contributor

Robust rollback support, like you could achieve with an SQL database with schema transactions (such as PostgreSQL) is not directly possible with Cassandra.

I'm also not a great fan of them, since automated solutions can never account for data changes, and the possible destruction of data that a rollback might cause should be painfully visible to administrators and developers such that they cannot accidentally ignore them.

If you are creating/re-creating the database for development, you can use the reset command, or just rerun migrate with --force if you know you don't need to clean up any leftovers.

That said, I can think of some possible solutions, none of which I consider fantastic. I do plan on adding Python migrations relatively soon, but they would be most useful for doing complex data modifications, which can't really be rolled back anyway. Please tell me what you think, such that I can understand your use case :)

  • Write migrations using a domain-specific language that represents the Cassandra model, then derive rollback instructions from it. Such approach is usually part of a larger ORM, that already needs to have a model of database structures. Just modeling the Cassandra DB structures would be much larger than this project (as I could not find any existing Python library that does it).
  • Observe the schema before and after the migration, and attempt to find out what changed. This is probably way too error-prone to ever be a reliable solution.
  • Allow users to specify explicit rollback queries. That would require complicating the format from simple CQL queries, possibly relying on comments. This is the most realistic solution given the scope of the project.

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