Skip to content
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

fix: block out of order migrations in migrations tool #7693

Merged
merged 2 commits into from
Jun 23, 2021

Conversation

jzaralim
Copy link
Contributor

Description

Adds a check to make sure the version specified by apply -v <number> is greater than the last applied version.

Testing done

Unit and integration tests

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@jzaralim jzaralim requested a review from a team as a code owner June 17, 2021 20:00
@jzaralim jzaralim requested a review from vcrfxia June 17, 2021 20:00
Copy link
Contributor

@vcrfxia vcrfxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jzaralim ! I like this solution -- very clean :)

if (version < minimumVersion) {
throw new MigrationException(
"Version must be newer than the last version migrated. Last version migrated was "
+ (minimumVersion - 1));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it's not great that apply() gets the latest migrated version, transforms that into minimumVersion to pass to loadMigrationsToApply(), and then loadMigrationsToApply() undoes the transformation again in this error message. Maybe we can have apply() directly pass the last migrated version and move the logic for computing minimumVersion into loadMigrationsToApply() instead? Less coupling between the two methods that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@jzaralim jzaralim merged commit 1d617d3 into confluentinc:master Jun 23, 2021
@jzaralim jzaralim deleted the order branch June 23, 2021 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants