mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
#2600 - Pending drops migration with the same version of the target migration cause trouble
This commit is contained in:
1 parent
66aa772f4a
commit
de4140aaac
2 files changed
+35
-20
No files matched your search
+20
-18
@@ -1,17 +1,5 @@
|
||||
package io.ebeaninternal.dbmigration;
|
||||
|
||||
import static io.ebeaninternal.api.PlatformMatch.matchPlatform;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.annotation.Platform;
|
||||
@@ -50,15 +38,21 @@ import io.ebeaninternal.dbmigration.ddlgeneration.DdlOptions;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite;
|
||||
import io.ebeaninternal.dbmigration.migration.Migration;
|
||||
import io.ebeaninternal.dbmigration.migrationreader.MigrationXmlWriter;
|
||||
import io.ebeaninternal.dbmigration.model.CurrentModel;
|
||||
import io.ebeaninternal.dbmigration.model.MConfiguration;
|
||||
import io.ebeaninternal.dbmigration.model.MigrationModel;
|
||||
import io.ebeaninternal.dbmigration.model.ModelContainer;
|
||||
import io.ebeaninternal.dbmigration.model.ModelDiff;
|
||||
import io.ebeaninternal.dbmigration.model.PlatformDdlWriter;
|
||||
import io.ebeaninternal.dbmigration.model.*;
|
||||
import io.ebeaninternal.extraddl.model.DdlScript;
|
||||
import io.ebeaninternal.extraddl.model.ExtraDdl;
|
||||
import io.ebeaninternal.extraddl.model.ExtraDdlXmlReader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import static io.ebeaninternal.api.PlatformMatch.matchPlatform;
|
||||
|
||||
/**
|
||||
* Generates DB Migration xml and sql scripts.
|
||||
@@ -611,6 +605,7 @@ public class DefaultDbMigration implements DbMigration {
|
||||
if (version == null) {
|
||||
version = (nextVersion != null) ? nextVersion : initialVersion;
|
||||
}
|
||||
checkDropVersion(version, dropsFor);
|
||||
|
||||
String fullVersion = applyPrefix + version;
|
||||
String name = name();
|
||||
@@ -626,6 +621,13 @@ public class DefaultDbMigration implements DbMigration {
|
||||
return fullVersion;
|
||||
}
|
||||
|
||||
void checkDropVersion(String version, String dropsFor) {
|
||||
if (dropsFor != null && dropsFor.equals(version)) {
|
||||
throw new IllegalArgumentException("The next migration version must not be the same as the pending drops version of " +
|
||||
dropsFor + ". Please make the next migration version higher than " + dropsFor + ".");
|
||||
}
|
||||
}
|
||||
|
||||
String trimDropsFor(String dropsFor) {
|
||||
if (dropsFor.startsWith("V") || dropsFor.startsWith("v")) {
|
||||
dropsFor = dropsFor.substring(1);
|
||||
|
||||
Reference in new issue
Block a user