-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
Pending drops migration with the same version of the target migration cause trouble #2600
Comments
Yes. I think Ebean should throw a nice error here saying that they can't be the same. |
There is a second case where we generate a migration that is drops only. In this case a model.xml is generated but no migration sql is generated (as it would be empty). e.g.
At this point we maybe want to generate a 1.1 migration (from the 1.1 drops) but we can't do that. There might be a better way to deal with this case by detecting when a "drops only" migration is generated and not "consuming" a version number for that. Like:
So SummaryYes, we can't use the same version number as pendingDropsFor - so will fix that by detected that and throwing a reasonable exception. In future we might get an improve for the case where a migration is generated that is for drops only such that it doesn't effectively consume a version number - but this does need some more thinking. |
Thank you for the quick answer and fix! |
Expected behavior
Ebean generate migration successfully.
Actual behavior
Ebean are allowing the user to set the
ddl.migration.version and ddl.migration.pendingDropsFor
with the same version, this cause trouble since the generated files will have the same vertion that the pending drops is target on.The current behavior is that Ebean crash with a NullPointException in the next time a migration generation is launched, I inspect the source code and figure out that is happened because Ebean are loading the pending drops model before the migration that is the source of the pending drops for.
Should Ebean fail to prevent this behavior when generate a migration with those property in such stste or fix the order that migration are loaded and continue allowing user to do that?
Steps to reproduce
System.setProperty("ddl.migration.version", "1.0")
System.setProperty("ddl.migration.version", "1.0"); System.setProperty("ddl.migration.pendingDropsFor", "1.0");
That step will produce the files and succeed:
The step 5 result will be something like:
The text was updated successfully, but these errors were encountered: