Comments (11)
Thanks @lecaillon
The use case is actually to get the db back to a stable state after a faulty migration. E.g. migration 1.4
broke something (although got successfully applied) so need to revert back to 1.3
. I guess this could be achieved by rolling forward i.e. deploying a new 1.5
script to revert the changes in 1.4
but having a rollback feature would make it convenient for CI/CD. The steps would be
- Run migration x
- Run tests
- If tests fail revert x, otherwise mark the deployment as success
from evolve.
We found DB migration rollbacks is problematic (although it sounds a nice feature). We ended up with
- ensuring database changes are always backward compatible
- rolling forward i.e. instead of rolling back a previous one, create a new migration with
from evolve.
Thanks for the feedback @IndikaUdagedara It is very interresting. Indeed I had already heard of that issue. I keep that in mind for that feature.
from evolve.
@IndikaUdagedara Thanks for the feedback. Appreciate it.
I know EF, Flyway and others have that sort of feature. But I can not see a real use case for it. Can you give me an example please ?
from evolve.
@lecaillon Is there any update related to this?
At the company I work for, I develop a .Net Core tool using Evolve, as part of our CI/CD project. It is going to be finished soon. Thus, a rollback feature is extremely important to us.
We could offer payment, if needed.
Please let me know what the plan is
from evolve.
In your opinion, what should be the behavior of Evolve in this case ?
Assume there are 4 applied migrations: V1.1, V1.2, V1.3, V1.4
And only 1 undo migration: U1.3
Is it allowed to rollback to V1.2 without a U1.4 script?
Is it the responsability of the user to know what is ok or not, or Evolve should only accept to rollback to a version where all the undo migration are defined ?
from evolve.
I'm looking forward to such feature too. I believe rolling forward, like @IndikaUdagedara said, is the way to go. I use to create my rollback scripts on a separated directory, not listed in Locations
, and if needed I just move it to be rolled out forward on a new version.
from evolve.
Rolling forward not so easy to do when you embed the scripts. That would involve another deployment.
from evolve.
If you ever consider to actually support rollback i suggest looking at pop/soda (https://gobuffalo.io/en/docs/db/toolbox, https://github.com/gobuffalo/pop). All migrations have an up and a down migration by default. When testing locally it is pretty convinient to just migrate down the migration you just made that you want to change. We have not had any situations where we use it in production.
from evolve.
Hey guys it would be indeed great to see this feature.
My use case is a continuous deployment pipeline, where for every deployment we want to be able to deploy the binaries with database changes but also rollback the database schema if the application goes back one version.
It would be good to rollback up to a specific point: per example if I use rollback V_3.sql, it would undo the migrations backwards until V_3.sql
There's this tool, dbmate, that we use for clickhouse that in each .sql file it includes a migrate part and another rollback part (two sections) so the tool know which one to apply when needed: https://github.com/amacneil/dbmate
from evolve.
You can have 2 files v1_1__CreateTable.up.sql
and v1_1__CreateTable.down.sql
.
Now, you can throw error if up
and down
files don't match which would make it more robust and reliable. And people who may need only up
can pass a flag like --no-rollback
.
The up migrations would run as usual in ascending order and the down will run in descending order.
from evolve.
Related Issues (20)
- Issue while using Evolve with MySQL HOT 1
- Exception on long running migration when using TransactionKind.CommitAll HOT 6
- [Logging] Documentation missing
- Can command line interface accept password from environment HOT 1
- Bug: Error when trying to migrate large files
- Error: `syntax error at or near "-" at character 30` when running Evolve.Erase()
- [question] how to capture all SQL so that it can be applied by some other tool? HOT 1
- Feature Request: Code-based Migrations
- Allow versions longer than long.MaxValue
- Unable to load shared library 'SQLite.Interop.dll' HOT 5
- Unable to apply migration from two different sql files HOT 1
- Inconsistent behavior in treating paths in Evolve.Evolve() on Windows and Linux HOT 1
- Tool does not work the .NET 7 HOT 2
- Use Microsoft.Data.SqlClient HOT 1
- evolve and Postgres get error "SHOW VARIABLES LIKE '" HOT 4
- [Evolve Exception] CREATE INDEX CONCURRENTLY cannot be executed within a pipeline Sql query: -- evolve-tx-off
- Cannot proceed, because event scheduler is disabled. HOT 1
- Version sorting HOT 1
- Is the timeout capped at 60 seconds somewhere? HOT 5
- Migrate from System.Data.SqlClient to Microsoft.Data.SqlClient
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from evolve.