Search code examples
mavenliquibase

Why does liquibase not create the tables but it creates the changelog?


I have the following maven config:

    <profile>
      <id>liquibase-default</id>
      <activation>
        <property>
          <name>!updateSQL</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <configuration>
              <changeLogFile>src/main/database/releases.xml</changeLogFile>
              <driver>oracle.jdbc.driver.OracleDriver</driver>
              <url><url></url>
              <username><user></username>
              <password><pw></password>
              <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
            </configuration>
            <executions>
              <execution>
                <phase>process-resources</phase>
                <goals>
                  <goal>changelogSync</goal>
                  <goal>update</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

as soon as this runs on an empty database two tables are created:

  • DATABASECHANGELOG
  • DATABASECHANGELOGLOCK

But the actual tables which should get created are not there. All the create statements are written in the DATABASECHANGELOG as if liquibase created them but they arent created.

How to tell liquibase to create the tables?


Solution

  • I'm not familiar with Maven, but you have two Liquibase command listed in the "goals" section:

    changelogSync and update

    Since the changelogSync command is listed first, I assume it's going be executed first. This command is going to take all of the changesets listed in your releases.xml changelog and insert them into the databasechangelog table, making it look like Liquibase applied them to your database, even though it actually didn't. So when the update command executes there are no "pending" changesets to be applied to your database.

    https://docs.liquibase.com/commands/change-tracking/changelog-sync.html