Giter Club home page Giter Club logo

Comments (11)

IndikaUdagedara avatar IndikaUdagedara commented on July 28, 2024 9

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.

IndikaUdagedara avatar IndikaUdagedara commented on July 28, 2024 3

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.

lecaillon avatar lecaillon commented on July 28, 2024 1

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.

lecaillon avatar lecaillon commented on July 28, 2024

@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.

amiralgazi avatar amiralgazi commented on July 28, 2024

@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.

lecaillon avatar lecaillon commented on July 28, 2024

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.

mfedatto avatar mfedatto commented on July 28, 2024

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.

kellielellie1 avatar kellielellie1 commented on July 28, 2024

Rolling forward not so easy to do when you embed the scripts. That would involve another deployment.

from evolve.

Lothrandir avatar Lothrandir commented on July 28, 2024

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.

madison-tobal-shift avatar madison-tobal-shift commented on July 28, 2024

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.

vish9812 avatar vish9812 commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.