New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposed fix for #5442 - command "unexpectedChangesets" always reports at least 1 unexpected changeset with initial tag in database #5446
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Tylorjg,
Thank you for adding submitting this PR to fix #5442. I was thinking maybe we can only update isSameAs()
by also checking whether filepath
is equals to "liquibase-internal"
. Something like this:
public boolean isSameAs(ChangeSet changeSet) {
return isSamePath("liquibase-internal") || (
this.getId().equalsIgnoreCase(changeSet.getId())
&& this.getAuthor().equalsIgnoreCase(changeSet.getAuthor())
&& isSamePath(changeSet.getFilePath()));
}
Then we don't need to create a new method nor update ExpectedChangesVisitor
class.
Regarding tests, I think it would be nice if we can add some integration test here by creating a new class (UnexpectedChangesetsCommandStepTest), for adding this test you can also use CommandUtil
test class where you have a runTag()
and probably you can also add a runUnexpectedChangeset()
to validate the given issue.
Please let me know if you have any question/concerns.
Thanks,
Daniel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
Thanks @Tylorjg for submitting this PR and addressing my review comment. I have manually tested this change, plus also adding a basic integration test to validate your fix against MySQL in this case, but it could against any DB.
Build and test checks have been successfully executed (there are some functional test failing, but that doesn't seem to be related with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tylorjg @filipelautert @MalloD12
The fix introduces a regression. So, if you execute the following commands:
- liquibase tag tag1
- liquibase update
- liquibase history
you will observe that it appears as though nothing was deployed; the databasechangelog will be empty, but the deployed objects will exist in the database.
25f033b
to
c4de18c
Compare
liquibase-standard/src/main/java/liquibase/changelog/RanChangeSet.java
Outdated
Show resolved
Hide resolved
…nction, isSameAsIgnoreLiquibaseInternalChangeset to ignore the liquibase-internal filepath.
…baseInternalChangeset
…baseInternalChangeset
- Add runUnexpectedChangeSet method to CommandUtil class. - Add unexpected changeset test to validate running a tag to the database is not reported as a unexpected changeset.
…so I expanded the removeIf predicate to be two conditions. This solves the issue of changesets not showing up in the DBCL table.
b6e67c9
to
52cacf1
Compare
Impact
Description
Issue #5442 outlines an odd behavior where the
unexpected-changesets
command shows thetag
changeset as unexpected. If using thetag
command itself, a changeset is not added to the changelog, but an internal Liquibase changeset will be added to the DBCL table. This would cause theunexpected-changesets
to always show the internal Liquibase changeset as unexpected. Side note, thegenerate-changelog
does not create the changeset in a changelog if it exists in the DBCL, so there isn't a way to make the tag expected.This fix adds a function that is called first to determine if the file path is the liquibase-internal changeset. If it is, it removes it from the unexpected list.
Fixes #5442
Things to be aware of
I couldn't find a way to capture the file path for the ran changeset in the RanChangesSet.java file, so I did the same call that occurs in the isSameAs function (occurs in the isSamePath function technically), so it could be refactored to be more efficient.
Things to worry about
There isn't any additional tests associated with the change. I have found that there is a file unexpectedChangesets.test.groovy, but was unsure how to get the
tag
command to execute first. I would be happy to write test cases/modify the existing ones.Additional Context
N/A