在不同的模式上运行相同的liquibase迁移

时间:2018-02-13 07:34:15

标签: java database maven database-migration liquibase

我用我的数据库实体类和Maven架构编写了一个Liquibase项目。我们的想法是能够运行liquibase changelog并生成定义的模式。这部分工作正常,但仅适用于 架构。我希望能够将Liquibase另一个schemaName作为参数,以便在该架构上运行更新,作为参数接收。

我知道如何将Liquibase外部schemaName

<createTable tableName="client" schemaName="${schemaName}">
            <column name="id" type="bigint">
                <constraints primaryKey="true" nullable="false" />
            </column>

再次编译架构:

mvn compile liquibase:update -DschemaName=my-schema

问题在于它需要schemaName文件中定义的相同liquibase.properties,因此这不是真正的参数化。我可以给它一个schemaName作为属性,但是还需要在属性文件中更改以匹配命令行参数。

liquibase.properties

driver: org.postgresql.Driver
# currentSchema needs to be changed every time --> problem
url: jdbc:postgresql://localhost:5431/my-db?currentSchema=my-schema
username: postgres
password: root

否则,它不会将 databasechangelog databasechangeloglock 创建为作为参数提供的架构,从而无法跟踪该架构中的更改。

的pom.xml

<!-- use Liquibase plugin -->
            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.5.3</version>
                <configuration>
                    <propertyFile>liquibase.properties</propertyFile>
                    <changeLogFile>db/master.xml</changeLogFile>
                </configuration>
            </plugin>

我想:

  1. schemaName作为命令行参数
  2. 在某些properties file
  3. 上进行设置

    肯定这两个地方。怎么会这样做?

0 个答案:

没有答案
相关问题