6

I'm trying to create an empty database using liqubase. I use this approach to do this, but the problem is it doesn't work for me.

I use Postgresql 10 and there are my configurations for maven and liqubase:

 <plugin>
          <groupId>org.liquibase</groupId>
          <artifactId>liquibase-maven-plugin</artifactId>
          <version>3.0.5</version>
          <configuration>
             <propertyFile>src/main/resources/liquibase/liquibase.properties</propertyFile>
          </configuration>
          <executions>
              <execution>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>update</goal>
                    </goals>
              </execution>
          </executions>
  </plugin>

And my liqubase.properties:

changeLogFile=src/main/resources/liquibase/db.changelog.xml
driver=org.postgresql.Driver
dropFirst=false
url=jdbc:postgresql://localhost:5432/auth?createDatabaseIfNotExist=true
username=postgres
password=root

The error on mvn clean package is:

org.postgresql.util.PSQLException: FATAL: database "auth" does not exist

2 Answers 2

4

Liquibase will not create a database that does not exist at all. I also imagine that the url parameter ?createDatabaseIfNotExist=true that is referenced in the linked question/answer is probably MySql specific.

Sign up to request clarification or add additional context in comments.

Comments

4

This is slightly beyond the scope of your question, but you could use liquibase against a Docker postgres instance, and per the docker-library's documentation on ENVIRONMENT VARIABLES, set POSTGRES_DB to "auth" (in your case), and it will create the "auth" db when the docker image launches, with which liquibase can then interact.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.