Can you clear liquibase checksums for a given file only?

烂漫一生 提交于 2019-12-04 04:04:21

I don't think there is another command or a parameter to clearCheckSums that does this.

But you could do this manually. All that clearCheckSums does is nullifying the MD5SUM column of the databasechangelog table.

So something like:

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

should work.

(I haven't tested this SQL. It's just an example - so before you apply this to your production database make sure this works on a development db.)

If you are using a Maven plugin for Liquibase, you may have something like this on your pom.xml file, where you use clearCheckSum as a parameter for each execution(you may want to split the files as I did in here):

        <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>

You can always use the parameterized build with Maven, adding default values as:

<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>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!