如果你有不同的模式名稱爲每個租戶,可能比你想使用Maven插件liquibase。
您可能想聲明不同的執行爲如下每個模式:
<build>
<plugins>
<plugin>
<!--NOTE: clearCheckSums=true attribute will make the changesets run only once.
The runOnChange attribute added to changesets will not work as originally intended.-->
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${database.liquibase.version}</version>
<executions>
<execution>
<id>admin-schema-database-update</id>
<phase>process-resources</phase>
<configuration>
<changeLogFile>admin-schema.db.changelog-master.xml</changeLogFile>
<driver>${database.driver}</driver>
<contexts>${database.liquibasecontext}</contexts>
<url>${database.server.url}</url>
<username>${database.adminschema.username}</username>
<password>${database.adminschema.password}</password>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
<outputDefaultSchema>true</outputDefaultSchema>
<verbose>true</verbose>
<logging>${database.liquibase.logging}</logging>
<propertyFileWillOverride>false</propertyFileWillOverride>
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
<execution>
<id>user-schema-database-update</id>
<phase>process-resources</phase>
<configuration>
<changeLogFile>user-schema.db.changelog-master.xml</changeLogFile>
<driver>${database.driver}</driver>
<contexts>${database.liquibasecontext}</contexts>
<url>${database.server.url}</url>
<username>${database.username}</username>
<password>${database.password}</password>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
<outputDefaultSchema>true</outputDefaultSchema>
<verbose>true</verbose>
<logging>${database.liquibase.logging}</logging>
<propertyFileWillOverride>false</propertyFileWillOverride>
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-mssql</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-oracle</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.csv</include>
<include>**/*.sql</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.xml</exclude>
<exclude>**/*.csv</exclude>
<exclude>**/*.sql</exclude>
</excludes>
</resource>
</resources>
</build>
您可以隨時使用的參數用Maven構建,將默認值:
<properties>
<liquibase.clearCheckSums>true</liquibase.clearCheckSums>
<database.username>userSchema</database.username>
<database.password>myUserPassword</database.password>
<database.adminschema.username>adminSchema</database.adminschema.username>
<database.adminschema.password>myAdminPassword</database.adminschema.password>
<database.liquibasecontext>!IntegrationTesting</database.liquibasecontext>
</properties>
希望,這可能幫你。