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

Implicit baseline triggered by baselineOnMigrate does not respect baselineVersion #940

JohnSAdair opened this issue Jan 23, 2015 · 8 comments


Copy link

@JohnSAdair JohnSAdair commented Jan 23, 2015

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.

Copy link

@JohnSAdair JohnSAdair commented Jan 23, 2015

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;

  public static void setup() throws SQLException {
    dataSource = JdbcConnectionPool.create("jdbc:h2:mem:test", "sa", "sa");

  public static void cleanup() throws SQLException {

  public void testFlywayExplicitBaseline() throws SQLException {

  // 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.
  public void testFlywayImplicitBaseline() throws SQLException {

  private void exerciseFlyway(boolean explicitBaseline) {
    Flyway flyway = new Flyway();
    if (explicitBaseline) {
Copy link

@JohnSAdair JohnSAdair commented Jan 23, 2015

Workaround is to call baseline explicitly before migration, and catch and ignore the exceptions that come from trying to baseline more than once.

Copy link

@axelfontaine axelfontaine commented Mar 4, 2015

This was somehow fixed by another fix to baseline. I've added another test case just to be on the safe side.


axelfontaine added a commit to flyway/ that referenced this issue Mar 4, 2015
jmahonin added a commit to jmahonin/flyway that referenced this issue Jul 15, 2015
Copy link

@meowfaceman meowfaceman commented May 20, 2016

I've just run into this issue on Spring-Boot 1.3.2, which uses Flyway 3.2.1.

Copy link

@oey oey commented Aug 30, 2017

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 Baseline command it baselines from specified version, but BaselineOnMigrate tries to run all migrations.

Copy link

@Webenius Webenius commented Feb 8, 2018

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:

<bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
        <property name="baselineOnMigrate" value="true" />
        <property name="baselineVersionAsString" value="1.5" />
        <property name="dataSource" ref="dataSource" />

baselineVersion is ignored too:

<bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
        <property name="baselineOnMigrate" value="true" />
        <property name="baselineVersion">
            <bean class="org.flywaydb.core.api.MigrationVersion">
                <constructor-arg value="5"></constructor-arg>
        <property name="locations" value="classpath:db.migration" />
        <property name="dataSource" ref="dataSource" />

am I missing something or doing it wrong to get what I want? Any help will be appreciated.


Copy link

@ograndebe ograndebe commented Mar 20, 2018

I Had the same problem here. Even executing baselineOnMigrate or directly baseline command. Flyway tries to execute migrate all migrations.

Copy link

@kippm kippm commented Oct 8, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants