question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Precondition in databaseChangeLog should allow to skip the whole file

See original GitHub issue

Environment

Liquibase Version: 3.4

Liquibase Integration & Version: CLI

Liquibase Extension(s) & Version:

Database Vendor & Version:

Operating System Type & Version:

Description

There is no option to conditionally include a file or to skip executing file if preConditions in databaseChangeLog fails

Steps To Reproduce

List the steps to reproduce the behavior.

  1. Create ABC table
  2. Execute:
<databaseChangeLog xmlns='http://www.liquibase.org/xml/ns/dbchangelog' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd'>

    <preConditions onFail="CONTINUE"> <!-- CONTINUE not supported -->
        <not><tableExists tableName="ABC"/></not>
    </preConditions>

    <include file="tables.xml" relativeToChangelogFile="true"/>

</databaseChangeLog>

Actual Behavior

It fails because preConditions in databaseChangeLog supports only WARN and HALT. CONTINUE is not supported:

org.xml.sax.SAXParseException: cvc-enumeration-valid: Value 'CONTINUE' is not facet-valid with respect to enumeration '[HALT, WARN]'. It must be a value from the enumeration.

Expected/Desired Behavior

When ABC table exists, the whole databaseChangeLog should be skipped.

Additional Context

It was reported before: https://liquibase.jira.com/browse/CORE-1421 https://liquibase.jira.com/browse/CORE-917

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
nealeucommented, Oct 4, 2021

@CristianDuta It depends on your situation. We have some changelog files that we omit in order to reduce the number being loaded. In particular we now have e.g. changelog-2021-onwards.xml which is linked from changelog-2020-onwards.xml, and for production systems we set a year for database updates so we don’t load all the XML for changes that have all been applied. For CI, we also add in contexts to apply test data and some feature toggles.

0reactions
esselessecommented, Nov 11, 2022

What about this feature? Is it in process?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preconditions | Liquibase Docs
Preconditions. Preconditions are changelog or changeset tags which control the execution of an update based on the state of the database.
Read more >
Liquibase - How to skip changesets that have been executed
Is there a precondition at the changelog level that I can use to indicate "skip already executed changesets'? Or do I just create...
Read more >
Check database state and conditionally apply changes in the ...
Preconditions can be attached to changelogs or changesets to control the execution of an update based on the state of the database.
Read more >
How to fail Liquibase changeset when prerequisites are missing
</databaseChangeLog>. When the data file has more than 10GB of free space, the changeset executes, but when the precondition fails, you can ......
Read more >
Get Started | Core Liquibase Usage Concepts
These changelog files are stored in source control to enable collaboration. ... Preconditions can be applied to either the changelog as a whole...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found