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

Mark migration as already executed #190

Closed
Zarun1 opened this issue Feb 2, 2021 · 4 comments
Closed

Mark migration as already executed #190

Zarun1 opened this issue Feb 2, 2021 · 4 comments
Assignees

Comments

@Zarun1
Copy link
Contributor

Zarun1 commented Feb 2, 2021

I'm working on a database project where we use Evolve to handle migrations. A team member carelessly made changes to the production database without using Evolve. After realizing the situation, we added migration scripts matching those changes to version control. But now we have a production database where those changes have already been made, without Evolve knowing about it. The changes added new table columns that now have data in them, so we can't simply reverse the changes and then make them again using Evolve.

Would it be possible to add a feature to Evolve that allows marking migration scripts as already executed, without actually executing them? I believe it would only need to add rows to the database version history table that show the migrations have been run.

This is a feature supported by Flyway Teams (skipExecutingMigrations option). They've implemented this as part of the migrate command.

@lecaillon
Copy link
Owner

First, did you manage to "fix" the Evolve metadata table ? @Zarun1

Then, it is an interessant idea just need to think about the easiest way to implement it in Evolve.

@Zarun1
Copy link
Contributor Author

Zarun1 commented Feb 7, 2021

I did. First I manually added rows to the metadata table so that it looked like I used Evolve to run the migrations. Then I used "evolve repair" command to fix the checksums. The end result worked well.

@lecaillon lecaillon self-assigned this Feb 15, 2021
@lecaillon lecaillon added this to To do in Evolve 3.0.0 Feb 15, 2021
@lecaillon
Copy link
Owner

lecaillon commented Feb 15, 2021

What about an option called SkipNextMigrations used with the command migrate ? When run, Evolve would mark all next available migrations successful and stop.
This new option can be used with TargetVersion to only skip migrations until the targeted one (included).

  • Example with the Evolve CLI to skip all migrations until version 8.9 included:
evolve migrate postgresql -c "Server=localhost;Databa..." -l "C:\db\..." --skip-next-migrations true --target-version 8_9

@lecaillon lecaillon moved this from To do to In progress in Evolve 3.0.0 Mar 9, 2021
@lecaillon
Copy link
Owner

Available since Evolve 3.0.0-alpha6

@lecaillon lecaillon moved this from In progress to Done in Evolve 3.0.0 Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Evolve 3.0.0
  
Done
Development

No branches or pull requests

2 participants