-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Split calculate-checksum parameter changeSetIdentifier into changeSetPath / changesetId / changeSetAuthor #4463
Conversation
liquibase-standard/src/main/java/liquibase/integration/commandline/Main.java
Fixed
Show fixed
Hide fixed
final String changeLogFile = commandScope.getArgumentValue(CHANGELOG_FILE_ARG).replace('\\', '/'); | ||
final Database database = (Database) commandScope.getDependency(Database.class); | ||
|
||
List<String> parts = validateAndExtractParts(changeSetIdentifier, changeLogFile); | ||
Scope.getCurrentScope().getLog(getClass()).info(String.format("Calculating checksum for changeset %s", changeSetIdentifier)); | ||
Scope.getCurrentScope().getLog(getClass()).info(String.format("Calculating checksum for changeset %s", changeSetId)); |
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.
I think in this log message we should also include the other two arguments as well (path and author) since the three together compose the unique id of a changeset. Otherwise, there could be cases of having the same id multiple times in a changeset and this message can add a bit of confusion around.
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.
Added both arguments
if (changeSet == null) { | ||
throw new LiquibaseException(new IllegalArgumentException("No such changeSet: " + changeSetIdentifier)); | ||
throw new LiquibaseException(new IllegalArgumentException("No such changeSet: " + changeSetId)); |
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.
Same here.
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.
Added both arguments here aswell
@@ -1513,7 +1501,11 @@ protected void doMigration() throws Exception { | |||
liquibase.clearCheckSums(); | |||
return; | |||
} else if (COMMANDS.CALCULATE_CHECKSUM.equalsIgnoreCase(command)) { | |||
liquibase.calculateCheckSum(commandParams.iterator().next()); | |||
liquibase.calculateCheckSum( |
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.
I think here we should better perform the calculateCheckSum
call by the command scope as below to avoid keep using the deprecated method and just leave the Liquibase class methods for those who use liquibase as a library:
CommandResults commandResults = new CommandScope("calculateChecksum")
.addArgumentValue(DbUrlConnectionCommandStep.DATABASE_ARG, database)
.addArgumentValue(CalculateChecksumCommandStep.CHANGESET_PATH_ARG, changeSetPath)
.addArgumentValue(CalculateChecksumCommandStep.CHANGESET_ID_ARG, changeSetId)
.addArgumentValue(CalculateChecksumCommandStep.CHANGESET_AUTHOR_ARG, changeSetAuthor)
.addArgumentValue(CalculateChecksumCommandStep.CHANGELOG_FILE_ARG, this.changeLogFile)
.execute();
return commandResults.getResult(CalculateChecksumCommandStep.CHECKSUM_RESULT);
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.
Added the command scope call
@@ -104,7 +104,7 @@ private void cleanup() { | |||
|
|||
public LiquibaseCommandLine() { | |||
this.legacyPositionalArguments = new HashMap<>(); | |||
this.legacyPositionalArguments.put("calculatechecksum", CalculateChecksumCommandStep.CHANGESET_IDENTIFIER_ARG.getName()); |
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.
I think we should return this one to its previous state as well.
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.
Reverted to changeset identifier
Hi @JulienMa94, Thank you for submitting this PR for us, I have left you a few comments. Please have a look at them and please let me know if you have any questions. Thanks, |
Hi @MalloD12, thx for your review. I will look into your suggested changes as soon I can find some freetime. Greetings, |
Hi @MalloD12, I had some time to look into your suggestions and tried to refine the code to your suggestions. Unfortunately I have some problems with my local project setup and could not test my changes until now. liquibase/liquibase-standard/src/main/java/liquibase/Scope.java Lines 426 to 431 in e885b06
I tried to debug this problem but I could not resolve it and I am a bit clueless if it is a problem related to my code changes or to my local run configuration. Greetings |
.description("Changeset ID identifier of form filepath::id::author").build(); | ||
.description("The root changelog file").build(); | ||
|
||
CHANGESET_IDENTIFIER_ARG = builder.argument("changeSetIdentifier", String.class) |
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 @JulienMa94, I have been reviewing this PR yesterday and talked about it with the team and we have a few more things we might need to change. One of these is right now we are specifying the four arguments (CHANGESET_IDENTIFIER_ARG
, CHANGESET_PATH_ARG
, CHANGESET_ID_ARG
and CHANGESET_AUTHOR_ARG
) all defined as required. And I think this could be a bit ambiguous. What one of my team members suggest is we should make the four of them optional and then add a bit of logic in the run()
method to control which of these arguments we will use.
Doing the mentioned update will require us to update some of our command definition tests, plus in order to avoid confusion for other users I think we can add some examples like the ones below to command help. We can do this by calling commandDefinition.setHelpFooter()
in the adjustCommandDefinition()
method.
liquibase calculateCheckSum --changeSetIdentifier myFile::myId::myAuthor
and
liquibase calculatCheckSum --changesetId myId --changesetAuthor myAuthor --changesetPath myPath
If you need any help I'm here to help/assist you as you need, or I can even help doing these changes if you don't have any time constraints.
Thanks,
Daniel.
|
||
CHANGESET_IDENTIFIER_ARG = builder.argument("changeSetIdentifier", String.class) | ||
.required() | ||
.description("Changeset ID identifier of form filepath::id::author") |
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.
A minor thing. Can we use ChangeSet
instead of Changeset
argument descriptions? In this particular case, I would also remove the ID part as well.
I haven't faced this particular issue previously, but a team member told me he did and it got fixed for him by rebuilding the project. Thanks, |
Will try to rebuild it 👍🏽 |
Hi @MalloD12, I have implemented your suggestions and made the following parameters optional
Inside the run method there is a case distinction if a single parameter (changeSetIdentifier) and multiple parameters (changeSetPath, changeSetid, changeSetAuthor) are passed by the user. Manual Tests: I have not found any test to adjust. Let me know if there are any adjustments to the code or any test which have to be made. Greetings, |
Rebuilding did the trick, thx for the hint 👍🏼 |
liquibase-standard/src/main/java/liquibase/command/core/CalculateChecksumCommandStep.java
Fixed
Show fixed
Hide fixed
Hi @JulienMa94, Thank you for addressing the discussed changes. I reviewed them today and they look good to me. I have made a few minor text updates, plus fixed some command definition tests (as well as added one happy path test by making use of the three new arguments). We are having a build issue when trying to publish artifacts generated from a contributor branch and the team is already working on it. Before approving this PR I need to hold and wait until that issue is resolved, since once the build is successful some other tests should be triggered. I hope this gets fixed, so we can move forward with this one next week. Again, thank you for all the effort you have been doing. Thanks, |
Hi @MalloD12, no problem I will be waiting and hoping that the issues will get fixed soon. Have a nice week, |
I refined the error message.
Greetings |
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.
Thank you, @JulienMa94 for taking care of this PR and addressing all changes we have been requesting you. I very appreciate your efforts.
Review and testing results:
Code changes look good to me. Happy path tests have been added. Which I think complementary with some extra manual test and maybe functional test should be good enough.
Build and most of the tests checks have been successfully executed, except for a MySQL job on the functional tests which will be addressed soon separately (for more details see #4863).
NOTE: PD ticket (internal ticket) to reflect this changes on our docs has been created.
Things to be aware of:
- None
Things to worry about:
- None
|
||
final boolean isChangeSetIdentifierPassed = changeSetIdentifier != null; | ||
|
||
validateIdentifierParameters(commandScope, changeSetIdentifier); |
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.
@JulienMa94 I extracted the parameters validation to a new method so it's easier to spot this change.
3dd4b95
to
0278603
Compare
…tPath / changesetId / changeSetAuthor
…o calculdate checksum command
- Minor text updates changing changeset to changeSet.
…nt ones. - Update calculate checksum definition test.
0278603
to
97017c5
Compare
Impact
TypeBug
APIBreakingChanges
newContributors
Description
As described in #3814 the calculate-checksum command was not able to parse arguments which contains
::
characters. So the user is not able to use this command in conjuction with changeset Identifiers containing::
.As suggested in the issue I have split the parameter changeSetIdentifier into three seperate parameters
Herefor I made changes to the
CalculateChecksumCommandStep
and introduced the parameters mentioned above. I had to adjust the calculate-checksum API in Main and the Liquibase class.So the user has to adjust his use of the calculate-checksum command with the new parameters like so.
liquibase calculate-checksum --changeSetPath="changelog.xml" --changeSetId="1::createTable" --changeSetAuthor="Me"
Fixes #3814
Things to be aware of
Things to worry about
Additional Context
Manual Test
Run config
Result