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

migrate version fails on empty database #160

Closed
Anonymous-Coward opened this issue Feb 10, 2020 · 5 comments · Fixed by #161
Closed

migrate version fails on empty database #160

Anonymous-Coward opened this issue Feb 10, 2020 · 5 comments · Fixed by #161
Assignees
Labels
Milestone

Comments

@Anonymous-Coward
Copy link

Steps to reproduce:

  • create an empty migrations directory
  • develop some migrations on a local database
  • create/configure a second environment, targeting another database, which is empty
  • run migrate version for the second environment, using a valid migration version

Expected results:

  • the second database gets updated to the specified version, even if it is not the last

Actual results:

  • the migrations execution fails with an error message stating that the changelog table is missing

Background: in continuous integration setups, you don't always want to migrate to the latest version. The migrations in the source code repository may be well ahead of what needs to be deployed into a test environment, therefore you only update the database for that test environment to the database version corresponding to the app version that gets deployed there. That test environment may get reset to the initial state upon each deployment.

Workaround that works: first run migrate up, and only then run migrate version . But that's not nice or convenient, especially when having a lot of migrations between head and what needs to be deployed.

harawata added a commit to harawata/migrations that referenced this issue Feb 11, 2020
@harawata harawata added the bug label Feb 11, 2020
@harawata harawata self-assigned this Feb 11, 2020
@harawata harawata added this to the 3.3.7 milestone Feb 11, 2020
@harawata
Copy link
Member

Thank you for the report, @Anonymous-Coward !

I have committed a fix.
It would be great if you could verify the fix using the latest 3.3.7-SNAPSHOT.

@Anonymous-Coward
Copy link
Author

I would love to test this, but I'm using mybatis migrations through the maven plugin, and unfortunately don't have the time to set up a test env right now. But I'm happy to hear it's fixed - it will eventually get pushed to the maven plugin too, I suppose.

@harawata
Copy link
Member

As it's been a while since the last release, we released 3.3.7.
https://repo1.maven.org/maven2/org/mybatis/mybatis-migrations/3.3.7/

The maven plugin hasn't been updated for a while as there has been no real change.
You can use a newer version (or a snapshot version) of Migrations by specifying the plugin dependency explicitly in your pom.xml.

<plugin>
  <groupId>org.mybatis.maven</groupId>
  <artifactId>migrations-maven-plugin</artifactId>
  <version>1.1.3</version>
...
  <dependencies>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-migrations</artifactId>
      <version>3.3.7</version>
    </dependency>
  </dependencies>
</plugin>

@Anonymous-Coward
Copy link
Author

Just checked, 3.3.7 is not yet available on mvnrepository.com. Do you have a repo URL for me too, or will it get published soon?

@harawata
Copy link
Member

It takes a while for a new version to show up on mvnrepository.com as they have index interval (I guess). It's now visible.
https://mvnrepository.com/artifact/org.mybatis/mybatis-migrations/3.3.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants