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
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.
这稍微超出了您的问题范围,但是您可以对Docker postgres实例使用liquibase,并根据docker-library关于环境变量的文档,将POSTGRES_DB
设置为“ auth”(在您的情况下),它将创建“当docker映像启动时,“身份验证”数据库将与liquibase进行交互。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.