-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implicit baseline triggered by baselineOnMigrate does not respect baselineVersion #940
Comments
I have a small maven project that illustrates the problem, but can't figure out how to attach it to the issue. Here's the junit test class. It also requires a V1 migration with invalid SQL and a V2 migration with valid SQL. import java.sql.SQLException;
import org.flywaydb.core.Flyway;
import org.h2.jdbcx.JdbcConnectionPool;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* Illustrates problem with baselineOnMigrate and baselineVersion.
*/
public class FlywayTest {
private static JdbcConnectionPool dataSource;
@BeforeClass
public static void setup() throws SQLException {
dataSource = JdbcConnectionPool.create("jdbc:h2:mem:test", "sa", "sa");
}
@AfterClass
public static void cleanup() throws SQLException {
dataSource.dispose();
}
@Test
public void testFlywayExplicitBaseline() throws SQLException {
exerciseFlyway(true);
}
// This test fails because the implicit baseline triggered by the
// migration does not respect the baseline version, and tries to
// execute the invalid SQL in version 1.
@Test
public void testFlywayImplicitBaseline() throws SQLException {
exerciseFlyway(false);
}
private void exerciseFlyway(boolean explicitBaseline) {
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setTable("schema_version");
flyway.setBaselineOnMigrate(true);
flyway.setLocations("migrations");
flyway.setBaselineVersion("2");
flyway.clean();
if (explicitBaseline) {
flyway.baseline();
}
flyway.migrate();
}
} |
Workaround is to call baseline explicitly before migration, and catch and ignore the exceptions that come from trying to baseline more than once. |
This was somehow fixed by another fix to baseline. I've added another test case just to be on the safe side. Cheers |
I've just run into this issue on Spring-Boot 1.3.2, which uses Flyway 3.2.1. |
I get this issue with the Command line tool. I've tested with Flyway 4.0.1, 4.1.1 and 4.2.0. Using the |
I'm using Postgresql & Flyway 5.0.0 in a spring (not boot) application and I want that flyway does not execute the migrations < 1.5 (even if it is run for the first time on an existing db with no flyway_schema_history). But it executes always all the migrations and ignores the value of baselineVersionAsString:
baselineVersion is ignored too:
am I missing something or doing it wrong to get what I want? Any help will be appreciated. Thanks |
I Had the same problem here. Even executing baselineOnMigrate or directly baseline command. Flyway tries to execute migrate all migrations. |
Still having this problem in version 6.0.4, that all migrations are executed, even though baselineOnMigrate is set to true. Using the command line on Windows, btw. |
When baseline is triggered implicitly by migration with baselineOnMigrate set to true, it does not respect the baseline version specified by baselineVersion, and instead tries to run all migrations.
Will attach SSCCE.
I would have thought this bug is the same problem as issue #842, but I am still seeing it in flyway 3.1.
The text was updated successfully, but these errors were encountered: