你能清除给定文件的liquibase校验和吗?

时间:2015-05-27 02:47:09

标签: liquibase

运行

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中的变更集的校验和。

由于

2 个答案:

答案 0 :(得分:14)

我认为clearCheckSums还有另一个命令或参数来执行此操作。

但你可以手动完成。 clearCheckSums所做的只是取消MD5SUM表的databasechangelog列。

类似于:

update databasechangelog set md5sum=null where filename like '%db.changelog-next.xml';

应该有效。

(我还没有测试过这个SQL。它只是一个例子 - 所以在你将它应用到生产数据库之前,请确保它适用于开发数据库。)

答案 1 :(得分:0)

如果你正在使用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>