#1147 - Refactor move DbMigration internals into io.ebeaninternal - change to use DbMigration.create() - move IdentityType handling into internal from DbIdentity

This commit is contained in:
rob bygrave
2017-10-04 20:49:04 +13:00
parent 62707caf64
commit 9f9ec8ef9f
4 changed files with 78 additions and 33 deletions
@@ -136,9 +136,33 @@ public class PlatformDdl {
* Return the identity type to use given the support in the underlying database
* platform for sequences and identity/autoincrement.
*/
public IdType useIdentityType(IdentityType modelIdentityType) {
public IdType useIdentityType(IdentityType modelIdentity) {
return dbIdentity.useIdentityType(modelIdentityType);
if (modelIdentity == null) {
// use the default
return dbIdentity.getIdType();
}
return identityType(modelIdentity, dbIdentity.getIdType(), dbIdentity.isSupportsSequence(), dbIdentity.isSupportsIdentity());
}
/**
* Determine the id type to use based on requested identityType and
* the support for that in the database platform.
*/
private IdType identityType(IdentityType modelIdentity, IdType platformIdType, boolean supportsSequence, boolean supportsIdentity) {
switch (modelIdentity) {
case GENERATOR:
return IdType.GENERATOR;
case EXTERNAL:
return IdType.EXTERNAL;
case SEQUENCE:
return supportsSequence ? IdType.SEQUENCE : platformIdType;
case IDENTITY:
return supportsIdentity ? IdType.IDENTITY : platformIdType;
default:
return platformIdType;
}
}
/**