preConditions onSqlOutput TEST configuration does not work for nested changelogs
See original GitHub issueLiquibase Version: 3.6.3 (but same code on master)
Liquibase Integration & Version: <Pick one: CLI, maven, gradle, spring boot, servlet, etc.> maven
Description
onSqlOutput
does not work, if it is used in a nested changelog.
Steps To Reproduce
- Create a config with changelog A importing changelog B.
- Add a changeset in B with a PreCondition which will always fail.
- Use the
update-sql
command
Actual Behavior
No error, and any SQL in B will be printed, although the condition failed
Expected/Desired Behavior
The command stopping/not outputing the SQL in B.
Workaround
Add an empty preCondition
config to all “parent” changelogs, with the setting onSqlOutput: TEST
Cause
liquibase.precondition.core.PreconditionContainer#check
processes preConditions in a top-down way.
Nested Containers will only be evaluated, if the parent’s testPrecondtion
is true:
if (testPrecondition) {
super.check(database, changeLog, changeSet, changeExecListener);
}
As soon as one does not or is missing (and defaults to IGNORE), all nested preconditions will not be tested and all SQL will be printed.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Preconditions | Liquibase Docs
Control what changesets are run and not run based on the state of the database. You can use all Liquibase preconditions in XML,...
Read more >2 preconditions in one liquibase changeset - Stack Overflow
It's not possible to create column inside condition. If I understand your problem, then you have two (maybe more) options:.
Read more >Precondition evaluation in nested changelog files
Hi everybody, I have the following situation. My master change log file contains two include entries (changelog files).
Read more >How to use Liquibase for the versioning of the database schema
In this article, I'll explain how Liquibase can be used in a Java project, with Spring/Hibernate, to version the database schema.
Read more >Howto set/override changeset description - Liquibase Forums
Next Re : Upgrading from 2.0.5 to 3.2.0 - Problem with preConditions ? Previous Re : Track Database changes made with out using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I added a PR to fix the issue.
Your new example helped a lot, thanks
Hello, I ran into this issue as well. Will this allow me to generate SQL with updateSQL that ignores the failures?
parent changelog.yaml:
child-changelog,yaml: databaseChangeLog:
My goal here is to generate the SQL only if the create-mocks property is defined, when using the updateSql command. Currently this seems to blow up no matter what I do in the parent changelog (adding onSqlOutput: TEST & onFail: CONTINUE, etc).
The reason I am doing this is for our sandboxes where rebuilding the entire database every time for developers is time consuming so we generate the SQL, clean it up, and then run it as a big blob.