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

When migrating content entries, migration version returned is erroneous if no migration was applied to one of the two environments #53

Open
yvesgurcan opened this issue Apr 26, 2023 · 2 comments

Comments

@yvesgurcan
Copy link
Contributor

yvesgurcan commented Apr 26, 2023

This issue is fairly similar to #52.

How to reproduce the bug

  • Init migrations on new environments called environment1 and environment2 using content storage as a method to track migrations. You can use a source environment to duplicate from for both of the environments if you want.
  • Create a migration and apply it to environment1.
  • Run npx migrations content --verbose --diff --source-environment-id environment1 --dest-environment-id environment2
  • You should see an error like this one: Different migration states detected. environment1 (1682093148544) !== environment2 (-Infinity)

Explanation of the issue

While the ID of the migration in environment1 is accurate (1682093148544), the ID of the migration in environment2 isn't (-Infinity) and is the outcome of this line of code:

return Math.max(...versions);

Since environment2 doesn't have any migration, doing Math.max() on it results in -Infinity. The command then compares -Infinity to 1682093148544, which doesn't make much sense.

Suggestions on how to solve the issue

  1. If no migration is found in one of the environments, relay that information to the user and abort the process. The upside is that it helps make sense of the issue to the user. I'm not sure if there is a downside to this.
@yvesgurcan
Copy link
Contributor Author

@bezoerb @tharders Let me know what you think about this!

@bezoerb
Copy link
Member

bezoerb commented Apr 28, 2023

Hey @yvesgurcan, i think it's a great idea to check if there are any versions available before doing Math.max(...) and show a more appropriate error message to the user :)

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

No branches or pull requests

2 participants