Liquibase always running changesets

Asked

Viewed 231 times

0

Hello, I have a problem running Liquibase with Maven + Spring Boot. The following occurs:

I have two schemas, schema1 and schema2. In the project, I have 3 scripts in native SQL: first create the two schema, then create the tables and third populate the data.

But every time I make one mvn clean install and then java -jar projeto-x-0.0.1.jar it says in the logs that schemas already exist. Even taking away the sql that creates the schemas first, the second script (that creates the tables) also gives error.

I would like to know how to do so that when I upload the project, it does not execute the same changesets that were already executed the first time. (Obs: the two liquibase tables, databasechangelog and databasechangeloglock, are being created in the public schema)

OBS: I found the cause: when I first go up, it creates the databasechangelog and databasechangeloglock tables in the public. But then when I go up the second time he creates in schema1. Does anyone know how to solve this problem?

1 answer

0


I managed to solve:

I removed the Liquibase-related Maven dependencies and added the plugin "Liquibase Maven Plugin"

With this, I normally configured according to the documentation, thus in pom.xml

<plugin>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>2.0.1</version>

  <configuration>
    <changeLogFile>db.changelog-master.xml</changeLogFile>
    <driver>org.hsqldb.jdbcDriver</driver>
    <url>jdbc:hsqldb:file:teste;shutdown=true</url>
    <username>seuusuario</username>
    <password></password>
    <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
    <verbose>true</verbose>
    <changelogSchemaName>public</changelogSchemaName>
    <defaultSchemaName>seuschema</defaultSchemaName>
  </configuration>
</plugin>

The magic is in the changelogSchemaName and defaultSchemaName attributes. Where the schemaName is where the version control data of Liquibase and defaultSchemaName will be.

Then you just turn around mvn clean package liquibase:update that magic happens.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.