您可以只清除给定文件的 liquibase 校验和吗?
Can you clear liquibase checksums for a given file only?
运行
liquibase --url=jdbc:oracle:thin:@localhost:1521/XE --
driver=oracle.jdbc.OracleDriver --changeLogFile=db.changelog-next.xml --
username=owner --password=xxxx --logLevel=info clearCheckSums
清除数据库中的所有校验和。有没有办法只清除 db.changelog-next.xml.
中变更集的校验和
谢谢
我认为 clearCheckSums
没有其他命令或参数可以执行此操作。
但您可以手动执行此操作。
clearCheckSums
所做的只是使 databasechangelog
table 的 MD5SUM
列无效。
所以是这样的:
update databasechangelog set md5sum=null where filename like '%db.changelog-next.xml';
应该可以。
(我还没有测试这个 SQL。这只是一个例子 - 所以在你将它应用到你的生产数据库之前确保它适用于开发数据库。)
如果您使用的是 Liquibase 的 Maven 插件,您的 pom.xml 文件中可能会有这样的内容,您在其中使用 clearCheckSum 作为每次执行的参数(您可能想像我一样拆分文件在这里做的):
<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>
<clearCheckSums>${liquibase.clearCheckSums}</clearCheckSums>
</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>
<clearCheckSums>${liquibase.clearCheckSums}</clearCheckSums>
</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>
运行
liquibase --url=jdbc:oracle:thin:@localhost:1521/XE --
driver=oracle.jdbc.OracleDriver --changeLogFile=db.changelog-next.xml --
username=owner --password=xxxx --logLevel=info clearCheckSums
清除数据库中的所有校验和。有没有办法只清除 db.changelog-next.xml.
中变更集的校验和谢谢
我认为 clearCheckSums
没有其他命令或参数可以执行此操作。
但您可以手动执行此操作。
clearCheckSums
所做的只是使 databasechangelog
table 的 MD5SUM
列无效。
所以是这样的:
update databasechangelog set md5sum=null where filename like '%db.changelog-next.xml';
应该可以。
(我还没有测试这个 SQL。这只是一个例子 - 所以在你将它应用到你的生产数据库之前确保它适用于开发数据库。)
如果您使用的是 Liquibase 的 Maven 插件,您的 pom.xml 文件中可能会有这样的内容,您在其中使用 clearCheckSum 作为每次执行的参数(您可能想像我一样拆分文件在这里做的):
<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>
<clearCheckSums>${liquibase.clearCheckSums}</clearCheckSums>
</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>
<clearCheckSums>${liquibase.clearCheckSums}</clearCheckSums>
</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>