mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-24 03:57:45 +00:00
Merge remote-tracking branch 'ebean/master' into fix-limit-constraint-names
# Conflicts: # src/test/resources/dbmigration/migrationtest/db2/1.0__initial.sql # src/test/resources/dbmigration/migrationtest/db2/1.1.sql # src/test/resources/dbmigration/migrationtest/db2/1.3.sql
This commit is contained in:
@@ -20,3 +20,4 @@ profiling/
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
*uuid.state
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.ebean;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Builds RawSql instances from a SQL string and column mappings.
|
||||
@@ -24,6 +25,15 @@ public interface RawSqlBuilder {
|
||||
return XServiceProvider.rawSql().resultSet(resultSet, propertyNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a SqlRow based on the resultSet and the dbTrueValue.
|
||||
* @throws SQLException
|
||||
*/
|
||||
static SqlRow sqlRow(ResultSet resultSet, final String dbTrueValue) throws SQLException {
|
||||
return XServiceProvider.rawSql().sqlRow(resultSet, dbTrueValue);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an unparsed RawSqlBuilder. Unlike a parsed one this query can not be
|
||||
* modified - so no additional WHERE or HAVING expressions can be added to
|
||||
|
||||
@@ -372,6 +372,16 @@ public class ServerConfig {
|
||||
*/
|
||||
private DbTypeConfig dbTypeConfig = new DbTypeConfig();
|
||||
|
||||
/**
|
||||
* The UUID version to use.
|
||||
*/
|
||||
private UuidVersion uuidVersion = UuidVersion.VERSION4;
|
||||
|
||||
/**
|
||||
* The UUID state file (for Version 1 UUIDs).
|
||||
*/
|
||||
private String uuidStateFile = "ebean-uuid.state";
|
||||
|
||||
private List<IdGenerator> idGenerators = new ArrayList<>();
|
||||
private List<BeanFindController> findControllers = new ArrayList<>();
|
||||
private List<BeanPersistController> persistControllers = new ArrayList<>();
|
||||
@@ -1891,6 +1901,34 @@ public class ServerConfig {
|
||||
this.dbTypeConfig.setDbUuid(dbUuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the UUID version mode.
|
||||
*/
|
||||
public UuidVersion getUuidVersion() {
|
||||
return uuidVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the UUID version mode.
|
||||
*/
|
||||
public void setUuidVersion(UuidVersion uuidVersion) {
|
||||
this.uuidVersion = uuidVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the UUID state file.
|
||||
*/
|
||||
public String getUuidStateFile() {
|
||||
return uuidStateFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the UUID state file.
|
||||
*/
|
||||
public void setUuidStateFile(String uuidStateFile) {
|
||||
this.uuidStateFile = uuidStateFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if LocalTime should be persisted with nanos precision.
|
||||
*/
|
||||
@@ -2816,6 +2854,10 @@ public class ServerConfig {
|
||||
if (p.getBoolean("uuidStoreAsBinary", false)) {
|
||||
dbTypeConfig.setDbUuid(DbUuid.BINARY);
|
||||
}
|
||||
|
||||
uuidVersion = p.getEnum(UuidVersion.class, "uuidVersion", uuidVersion);
|
||||
uuidStateFile = p.get("uuidStateFile", uuidStateFile);
|
||||
|
||||
localTimeWithNanos = p.getBoolean("localTimeWithNanos", localTimeWithNanos);
|
||||
jodaLocalTimeMode = p.get("jodaLocalTimeMode", jodaLocalTimeMode);
|
||||
|
||||
@@ -2836,6 +2878,22 @@ public class ServerConfig {
|
||||
ddlInitSql = p.get("ddl.initSql", ddlInitSql);
|
||||
ddlSeedSql = p.get("ddl.seedSql", ddlSeedSql);
|
||||
|
||||
// read tenant-configuration from config:
|
||||
// tenant.mode = NONE | DB | SCHEMA | CATALOG | PARTITION
|
||||
String mode = p.get("tenant.mode");
|
||||
if (mode != null) {
|
||||
for (TenantMode value : TenantMode.values()) {
|
||||
if (value.name().equalsIgnoreCase(mode)) {
|
||||
tenantMode = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentTenantProvider = createInstance(p, CurrentTenantProvider.class, "tenant.currentTenantProvider", currentTenantProvider);
|
||||
tenantCatalogProvider = createInstance(p, TenantCatalogProvider.class, "tenant.catalogProvider", tenantCatalogProvider);
|
||||
tenantSchemaProvider = createInstance(p, TenantSchemaProvider.class, "tenant.schemaProvider", tenantSchemaProvider);
|
||||
tenantPartitionColumn = p.get("tenant.partitionColumn", tenantPartitionColumn);
|
||||
classes = getClasses(p);
|
||||
}
|
||||
|
||||
@@ -3033,37 +3091,51 @@ public class ServerConfig {
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Specify how UUID is stored.
|
||||
*/
|
||||
public enum DbUuid {
|
||||
|
||||
|
||||
/**
|
||||
* Store using native UUID in H2 and Postgres and otherwise fallback to VARCHAR(40).
|
||||
*/
|
||||
AUTO_VARCHAR(true, false),
|
||||
AUTO_VARCHAR(true, false, false),
|
||||
|
||||
/**
|
||||
* Store using native UUID in H2 and Postgres and otherwise fallback to BINARY(16).
|
||||
*/
|
||||
AUTO_BINARY(true, true),
|
||||
AUTO_BINARY(true, true, false),
|
||||
|
||||
/**
|
||||
* Store using native UUID in H2 and Postgres and otherwise fallback to BINARY(16) with optimized packing.
|
||||
*/
|
||||
AUTO_BINARY_OPTIMIZED(true, true, true),
|
||||
|
||||
/**
|
||||
* Store using DB VARCHAR(40).
|
||||
*/
|
||||
VARCHAR(false, false),
|
||||
VARCHAR(false, false, false),
|
||||
|
||||
/**
|
||||
* Store using DB BINARY(16).
|
||||
*/
|
||||
BINARY(false, true);
|
||||
BINARY(false, true, false),
|
||||
|
||||
/**
|
||||
* Store using DB BINARY(16).
|
||||
*/
|
||||
BINARY_OPTIMIZED(false, true, true);
|
||||
|
||||
boolean nativeType;
|
||||
boolean binary;
|
||||
boolean binaryOptimized;
|
||||
|
||||
DbUuid(boolean nativeType, boolean binary) {
|
||||
DbUuid(boolean nativeType, boolean binary, boolean binaryOptimized) {
|
||||
this.nativeType = nativeType;
|
||||
this.binary = binary;
|
||||
this.binaryOptimized = binaryOptimized;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3079,5 +3151,18 @@ public class ServerConfig {
|
||||
public boolean useBinary() {
|
||||
return binary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true, if optimized packing should be used.
|
||||
*/
|
||||
public boolean useBinaryOptimized() {
|
||||
return binaryOptimized;
|
||||
}
|
||||
}
|
||||
|
||||
public enum UuidVersion {
|
||||
VERSION4,
|
||||
VERSION1,
|
||||
VERSION1RND
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,32 +8,40 @@ public enum TenantMode {
|
||||
/**
|
||||
* No multi-tenancy.
|
||||
*/
|
||||
NONE(false),
|
||||
NONE(false, true),
|
||||
|
||||
/**
|
||||
* Each Tenant has their own Database (javax.sql.DataSource)
|
||||
*/
|
||||
DB(true),
|
||||
DB(true, false),
|
||||
|
||||
/**
|
||||
* Each Tenant has their own Database schema.
|
||||
*/
|
||||
SCHEMA(true),
|
||||
SCHEMA(true, false),
|
||||
|
||||
/**
|
||||
* Each Tenant has their own Database but with in connection pool
|
||||
*/
|
||||
CATALOG(true),
|
||||
CATALOG(true, false),
|
||||
|
||||
/**
|
||||
* Tenants share tables but have a discriminator/partition column that partitions the data.
|
||||
*/
|
||||
PARTITION(false);
|
||||
PARTITION(false, true),
|
||||
|
||||
/**
|
||||
* Each Tenant has their own Database (javax.sql.DataSource), and there is also one master-database
|
||||
* (that holds configuration e.g.)
|
||||
*/
|
||||
DB_WITH_MASTER(true, true);
|
||||
|
||||
boolean dynamicDataSource;
|
||||
boolean ddlEnabled;
|
||||
|
||||
TenantMode(boolean dynamicDataSource) {
|
||||
TenantMode(boolean dynamicDataSource, boolean ddlEnabled) {
|
||||
this.dynamicDataSource = dynamicDataSource;
|
||||
this.ddlEnabled = ddlEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,4 +50,12 @@ public enum TenantMode {
|
||||
public boolean isDynamicDataSource() {
|
||||
return dynamicDataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if DDL is enabled.
|
||||
*/
|
||||
public boolean isDdlEnabled() {
|
||||
return ddlEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package io.ebean.service;
|
||||
|
||||
import io.ebean.RawSql;
|
||||
import io.ebean.RawSqlBuilder;
|
||||
import io.ebean.SqlRow;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Service provided by Ebean for parsing and column mapping raw SQL queries.
|
||||
@@ -24,4 +26,10 @@ public interface SpiRawSqlService {
|
||||
* Unparsed SQL so explicit column mapping expected.
|
||||
*/
|
||||
RawSqlBuilder unparsed(String sql);
|
||||
|
||||
/**
|
||||
* Create based on a JDBC ResultSet.
|
||||
* @throws SQLException
|
||||
*/
|
||||
SqlRow sqlRow(ResultSet resultSet, String dbTrueValue) throws SQLException;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DdlGenerator {
|
||||
this.jaxbPresent = serverConfig.getClassLoadConfig().isJavaxJAXBPresent();
|
||||
this.generateDdl = serverConfig.isDdlGenerate();
|
||||
this.createOnly = serverConfig.isDdlCreateOnly();
|
||||
if (serverConfig.getTenantMode().isDynamicDataSource() && serverConfig.isDdlRun()) {
|
||||
if (!serverConfig.getTenantMode().isDdlEnabled() && serverConfig.isDdlRun()) {
|
||||
log.warn("DDL can't be run on startup with TenantMode " + serverConfig.getTenantMode());
|
||||
this.runDdl = false;
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,9 @@ public class SplitColumns {
|
||||
* Return as an array of string column names.
|
||||
*/
|
||||
public static String[] split(String columns) {
|
||||
if (columns == null || columns.isEmpty()) {
|
||||
return new String[0];
|
||||
}
|
||||
return columns.split(",");
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ public final class BasicTypeConverter implements Serializable {
|
||||
/**
|
||||
* Convert the value to a UUID.
|
||||
*/
|
||||
public static UUID toUUID(Object value) {
|
||||
public static UUID toUUID(Object value, boolean optimizedBinary) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
@@ -188,7 +188,7 @@ public final class BasicTypeConverter implements Serializable {
|
||||
return UUID.fromString((String) value);
|
||||
}
|
||||
if (value instanceof byte[]) {
|
||||
return ScalarTypeUUIDBinary.convertFromBytes((byte[]) value);
|
||||
return ScalarTypeUUIDBinary.convertFromBytes((byte[]) value, optimizedBinary);
|
||||
}
|
||||
return UUID.fromString(value.toString());
|
||||
}
|
||||
|
||||
@@ -409,6 +409,7 @@ public class InternalConfiguration {
|
||||
private DataSourceSupplier dataSource() {
|
||||
switch (serverConfig.getTenantMode()) {
|
||||
case DB:
|
||||
case DB_WITH_MASTER:
|
||||
return new MultiTenantDbSupplier(serverConfig.getCurrentTenantProvider(), serverConfig.getTenantDataSourceProvider());
|
||||
case SCHEMA:
|
||||
return new MultiTenantDbSchemaSupplier(serverConfig.getCurrentTenantProvider(), serverConfig.getDataSource(), serverConfig.getReadOnlyDataSource(), serverConfig.getTenantSchemaProvider());
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.ebean.SqlQuery;
|
||||
import io.ebean.SqlRow;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.util.JdbcClose;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebeaninternal.api.BindParams;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiSqlQuery;
|
||||
@@ -173,8 +174,8 @@ public final class RelationalQueryRequest {
|
||||
* Read and return the next SqlRow.
|
||||
*/
|
||||
public SqlRow createNewRow(String dbTrueValue) throws SQLException {
|
||||
|
||||
SqlRow sqlRow = new DefaultSqlRow(estimateCapacity, 0.75f, dbTrueValue);
|
||||
ServerConfig.DbUuid dbUuid = ebeanServer.getServerConfig().getDbTypeConfig().getDbUuid();
|
||||
SqlRow sqlRow = new DefaultSqlRow(estimateCapacity, 0.75f, dbTrueValue, dbUuid.useBinaryOptimized());
|
||||
|
||||
int index = 0;
|
||||
for (String propertyName : propertyNames) {
|
||||
|
||||
@@ -29,7 +29,9 @@ import io.ebeaninternal.server.deploy.IndexDefinition;
|
||||
import io.ebeaninternal.server.deploy.InheritInfo;
|
||||
import io.ebeaninternal.server.deploy.TableJoin;
|
||||
import io.ebeaninternal.server.deploy.parse.DeployBeanInfo;
|
||||
import io.ebeaninternal.server.idgen.UuidIdGenerator;
|
||||
import io.ebeaninternal.server.idgen.UuidV1IdGenerator;
|
||||
import io.ebeaninternal.server.idgen.UuidV1RndIdGenerator;
|
||||
import io.ebeaninternal.server.idgen.UuidV4IdGenerator;
|
||||
import io.ebeaninternal.server.rawsql.SpiRawSql;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
@@ -844,8 +846,22 @@ public class DeployBeanDescriptor<T> {
|
||||
*/
|
||||
public void setUuidGenerator() {
|
||||
this.idType = IdType.EXTERNAL;
|
||||
this.idGeneratorName = UuidIdGenerator.AUTO_UUID;
|
||||
this.idGenerator = UuidIdGenerator.INSTANCE;
|
||||
this.idGeneratorName = PlatformIdGenerator.AUTO_UUID;
|
||||
|
||||
switch (serverConfig.getUuidVersion()) {
|
||||
case VERSION1:
|
||||
this.idGenerator = UuidV1IdGenerator.getInstance(serverConfig.getUuidStateFile());
|
||||
break;
|
||||
|
||||
case VERSION1RND:
|
||||
this.idGenerator = UuidV1RndIdGenerator.INSTANCE;
|
||||
break;
|
||||
|
||||
case VERSION4:
|
||||
default:
|
||||
this.idGenerator = UuidV4IdGenerator.INSTANCE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,6 +40,7 @@ class InExpression extends AbstractExpression {
|
||||
private List<Object> values() {
|
||||
List<Object> vals = new ArrayList<>(sourceValues.size());
|
||||
for (Object sourceValue : sourceValues) {
|
||||
assert sourceValue != null : "null is not allowed in in-queries";
|
||||
NamedParamHelp.valueAdd(vals, sourceValue);
|
||||
}
|
||||
return vals;
|
||||
@@ -66,7 +67,11 @@ class InExpression extends AbstractExpression {
|
||||
|
||||
@Override
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
|
||||
for (Object value : bindValues) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException("null values in 'in(...)' queries must be handled separately!");
|
||||
}
|
||||
}
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && !prop.isAssocId()) {
|
||||
prop = null;
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
package io.ebeaninternal.server.idgen;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* IdGenerator for java util UUID.
|
||||
*
|
||||
* It extends the UuidV1RndIdGenerator so that it can generate rfc4122 compliant Type 1 UUIDs.
|
||||
*
|
||||
* This generator produces real Type 1 UUIDs (best for sqlserver) - You should use this generator only,
|
||||
* if you can guarantee, that mac addess is uniqe.
|
||||
*/
|
||||
public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger("io.ebean.IDGEN");
|
||||
|
||||
private final File stateFile;
|
||||
|
||||
private byte[] nodeId = null;
|
||||
|
||||
private boolean canSaveState = true;
|
||||
|
||||
private static final Map<File, UuidV1IdGenerator> INSTANCES = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Returns an instance for given file.
|
||||
*/
|
||||
public static UuidV1IdGenerator getInstance(String file) {
|
||||
return INSTANCES.computeIfAbsent(new File(file), UuidV1IdGenerator::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance for given file.
|
||||
*/
|
||||
public static UuidV1IdGenerator getInstance(File file) {
|
||||
return INSTANCES.computeIfAbsent(file, UuidV1IdGenerator::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an alternative node id - set with the 'ebean.uuid.nodeId' system property.
|
||||
*/
|
||||
private static byte[] getAlternativeNodeId() {
|
||||
try {
|
||||
String altNodeId = System.getProperty("ebean.uuid.nodeId");
|
||||
if (altNodeId != null) {
|
||||
String[] components = altNodeId.split("-");
|
||||
if (components.length != 5) {
|
||||
throw new IllegalArgumentException("Invalid nodeId string: " + altNodeId);
|
||||
}
|
||||
byte[] nodeId = new byte[6];
|
||||
for (int i=0; i<5; i++) {
|
||||
nodeId[i] = Byte.decode("0x"+components[i]).byteValue();
|
||||
}
|
||||
return nodeId;
|
||||
}
|
||||
} catch (SecurityException se) {
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find hardware ID.
|
||||
*/
|
||||
private static byte[] getHardwareId() throws SocketException {
|
||||
final Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
|
||||
while (e.hasMoreElements()) {
|
||||
NetworkInterface network = e.nextElement();
|
||||
if (!network.isLoopback()) {
|
||||
return network.getHardwareAddress();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of UuidGenerator. Note that there should not be more
|
||||
* than one instance per stateFile.
|
||||
*/
|
||||
private UuidV1IdGenerator(final File stateFile) {
|
||||
super();
|
||||
this.stateFile = stateFile;
|
||||
try {
|
||||
// See, if there is an alternative MAC address set.
|
||||
nodeId = getAlternativeNodeId();
|
||||
if (nodeId != null) {
|
||||
logger.info("Using alternative MAC {} to generate Type 1 UUIDs", getNodeIdentifier());
|
||||
} else {
|
||||
nodeId = getHardwareId();
|
||||
logger.info("Using MAC {} to generate Type 1 UUIDs", getNodeIdentifier());
|
||||
}
|
||||
if (nodeId == null) {
|
||||
canSaveState = false;
|
||||
// RFC 4.5 use random portion for node
|
||||
nodeId = super.getNodeIdBytes();
|
||||
logger.error("Have to fall back to random node identifier {} (Reason: No suitable network interface found)", getNodeIdentifier());
|
||||
|
||||
} else {
|
||||
boolean flag = restoreState();
|
||||
UUID uuid = nextId(null);
|
||||
long ts = timeStamp.get();
|
||||
ts -= UUID_EPOCH_OFFSET;
|
||||
ts /= MILLIS_TO_UUID;
|
||||
|
||||
saveState();
|
||||
logger.debug("RestoreState: {}, ClockSeq {}, Timestamp {}, uuid {}, stateFile: {})", flag, clockSeq.get(),
|
||||
new Date(ts), uuid, stateFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
canSaveState = false;
|
||||
// RFC 4.5 use random portion for node
|
||||
nodeId = super.getNodeIdBytes();
|
||||
logger.error("Have to fall back to random node identifier {} (Reason: {} )", getNodeIdentifier(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Node-identifier (=MAC address) as string
|
||||
*/
|
||||
public String getNodeIdentifier() {
|
||||
if (nodeId == null) {
|
||||
return "none";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < nodeId.length; i++) {
|
||||
sb.append(String.format("%02X%s", nodeId[i], (i < nodeId.length - 1) ? "-" : ""));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the state from the state file.
|
||||
*/
|
||||
private boolean restoreState() throws IOException {
|
||||
Properties prop = new Properties();
|
||||
if (stateFile.exists()) {
|
||||
try (InputStream is = new FileInputStream(stateFile)) {
|
||||
prop.load(is);
|
||||
}
|
||||
}
|
||||
if (getNodeIdentifier().equals(prop.getProperty("nodeId"))) {
|
||||
try {
|
||||
Integer seq = Integer.valueOf(prop.getProperty("clockSeq")) & 0x3FFF;
|
||||
Long ts = Long.valueOf(prop.getProperty("timeStamp"));
|
||||
clockSeq.set(seq);
|
||||
timeStamp.set(ts);
|
||||
logger.debug("Restored state from '{}'", stateFile);
|
||||
return true;
|
||||
} catch (NumberFormatException nfe) {
|
||||
// nop
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the state to the state file;
|
||||
*/
|
||||
@Override
|
||||
protected void saveState() {
|
||||
if (!canSaveState) {
|
||||
return;
|
||||
}
|
||||
Properties prop = new Properties();
|
||||
prop.setProperty("nodeId", getNodeIdentifier());
|
||||
prop.setProperty("clockSeq", String.valueOf(clockSeq.get()));
|
||||
prop.setProperty("timeStamp", String.valueOf(timeStamp.get()));
|
||||
try (OutputStream os = new FileOutputStream(stateFile)) {
|
||||
prop.store(os, "ebean uuid state file");
|
||||
logger.debug("Persisted state to '{}'", stateFile);
|
||||
} catch (IOException e) {
|
||||
logger.error("Could not persist uuid state to '{}'", stateFile, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] getNodeIdBytes() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package io.ebeaninternal.server.idgen;
|
||||
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.config.dbplatform.PlatformIdGenerator;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* IdGenerator for (pseudo) type 1 UUIDs.
|
||||
*
|
||||
* This implementation generates a type 1 UUID according to
|
||||
* https://tools.ietf.org/html/rfc4122.html#section-4.2
|
||||
* but has no persistence storage. It generates a new random 47 bit node ID with every
|
||||
* UUID.
|
||||
*
|
||||
* Use this, if you want randomness in your UUIDs but want to take advantage of index
|
||||
* optimizations of the database. It may be good with AUTO_BINARY_OPTIMIZED and MySql.
|
||||
*
|
||||
* See: https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/
|
||||
*/
|
||||
public class UuidV1RndIdGenerator implements PlatformIdGenerator {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger("io.ebean.IDGEN");
|
||||
|
||||
// UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
|
||||
protected static final long UUID_EPOCH_OFFSET = 0x01B21DD213814000L;
|
||||
|
||||
// the resolution is 100ns
|
||||
protected static final long MILLIS_TO_UUID = 10000;
|
||||
|
||||
public static final UuidV1RndIdGenerator INSTANCE = new UuidV1RndIdGenerator();
|
||||
|
||||
protected final AtomicInteger clockSeq = new AtomicInteger((int) (Math.random() * 0x3FFF));
|
||||
|
||||
private final SecureRandom numberGenerator = new SecureRandom();
|
||||
|
||||
protected AtomicLong timeStamp = new AtomicLong(currentUuidTime());
|
||||
|
||||
private AtomicLong nanoToMilliOffset = new AtomicLong(currentUuidTime());
|
||||
|
||||
|
||||
/**
|
||||
* Returns the uuid epoch.
|
||||
*
|
||||
* This is the number of 100ns intervals since 1582-10-15 00:00:00
|
||||
*/
|
||||
private static long currentUuidTime() {
|
||||
return (System.currentTimeMillis() * MILLIS_TO_UUID) + UUID_EPOCH_OFFSET;
|
||||
}
|
||||
|
||||
public UuidV1RndIdGenerator() {
|
||||
computeNanoOffset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the internal offset between System.nanoTime() and System.currentTimeMillis().
|
||||
*/
|
||||
protected void computeNanoOffset() {
|
||||
long currentTime = currentUuidTime();
|
||||
long fromNanos = System.nanoTime() / 100L + nanoToMilliOffset.get();
|
||||
long offset = currentTime - fromNanos;
|
||||
if (Math.abs(offset) > MILLIS_TO_UUID * 1000 ) {
|
||||
nanoToMilliOffset.addAndGet(offset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to overwrite to save the state in a non volatile place.
|
||||
*/
|
||||
protected void saveState() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a random 47 bit value according to https://tools.ietf.org/html/rfc4122.html#section-4.5
|
||||
*/
|
||||
protected byte[] getNodeIdBytes() {
|
||||
byte[] idBytes = new byte[6];
|
||||
numberGenerator.nextBytes(idBytes);
|
||||
idBytes[0] |= 0x01; // set multicast bit.
|
||||
return idBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return UUID from UUID.randomUUID();
|
||||
*/
|
||||
@Override
|
||||
public UUID nextId(Transaction t) {
|
||||
long current = System.nanoTime() / 100L + nanoToMilliOffset.get();
|
||||
|
||||
long delta;
|
||||
int seq;
|
||||
do {
|
||||
seq = clockSeq.get();
|
||||
while (true) {
|
||||
long last = timeStamp.get();
|
||||
|
||||
delta = current - last;
|
||||
if (delta < -10000 * 20000) {
|
||||
logger.info("Clock skew of {} ms detected", delta / -10000);
|
||||
// The clock was adjusted back about 2 seconds, or we were generating a lot of ids too fast
|
||||
// if so, we try to set the current as last and also increment the clockSeq.
|
||||
synchronized (this) {
|
||||
if (clockSeq.compareAndSet(seq, seq + 1)) {
|
||||
timeStamp.set(current);
|
||||
saveState();
|
||||
computeNanoOffset();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If current is in the future (most of the cases) try to set it.
|
||||
if (delta > 0 && timeStamp.compareAndSet(last, current)) {
|
||||
break;
|
||||
} else if (timeStamp.compareAndSet(last, last + 1)) {
|
||||
// here we go, if we pull IDs too fast.
|
||||
current = last + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// verify, if this timestamp is for this clock sequence
|
||||
} while (seq != clockSeq.get());
|
||||
|
||||
// save state every 60 seconds
|
||||
if (delta > 60000 * 10000) {
|
||||
saveState();
|
||||
computeNanoOffset();
|
||||
}
|
||||
|
||||
long msb = current << 32; // time low
|
||||
msb |= (current & 0xFFFF00000000L) >> 16; // time mid
|
||||
msb |= 0x1000 | ((current >> 48) & 0x0FFF); // time hi and version 1
|
||||
|
||||
byte[] idBytes = getNodeIdBytes();
|
||||
|
||||
long lsb = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
lsb = (lsb << 8) | (idBytes[i] & 0xff);
|
||||
}
|
||||
|
||||
// RFC 4.1.1. Variant: is set with bits 10xx
|
||||
seq = seq & 0x3FFF | 0x8000;
|
||||
lsb |= (long) seq << 48;
|
||||
|
||||
return new UUID(msb, lsb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns "uuid".
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "uuid";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns false.
|
||||
*/
|
||||
@Override
|
||||
public boolean isDbSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignored for UUID as not required as a performance optimisation.
|
||||
*/
|
||||
@Override
|
||||
public void preAllocateIds(int allocateSize) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
}
|
||||
+6
-2
@@ -7,10 +7,14 @@ import java.util.UUID;
|
||||
|
||||
/**
|
||||
* IdGenerator for java util UUID.
|
||||
*
|
||||
* This generator generates a 60bit random UUID according to
|
||||
* https://tools.ietf.org/html/rfc4122.html#section-4.4
|
||||
* Use this generator if you want truly random UUIDs
|
||||
*/
|
||||
public class UuidIdGenerator implements PlatformIdGenerator {
|
||||
public class UuidV4IdGenerator implements PlatformIdGenerator {
|
||||
|
||||
public static final UuidIdGenerator INSTANCE = new UuidIdGenerator();
|
||||
public static final UuidV4IdGenerator INSTANCE = new UuidV4IdGenerator();
|
||||
|
||||
/**
|
||||
* Return UUID from UUID.randomUUID();
|
||||
@@ -34,6 +34,7 @@ public class DefaultSqlRow implements SqlRow {
|
||||
private static final long serialVersionUID = -3120927797041336242L;
|
||||
|
||||
private final String dbTrueValue;
|
||||
private final boolean optimizedBinaryUUID;
|
||||
|
||||
/**
|
||||
* The underlying map of property data.
|
||||
@@ -50,9 +51,10 @@ public class DefaultSqlRow implements SqlRow {
|
||||
* this map reaches its threshold (initialCapacity * loadFactor).
|
||||
* </p>
|
||||
*/
|
||||
public DefaultSqlRow(int initialCapacity, float loadFactor, String dbTrueValue) {
|
||||
public DefaultSqlRow(int initialCapacity, float loadFactor, String dbTrueValue, boolean optimizedBinaryUUID) {
|
||||
this.map = new LinkedHashMap<>(initialCapacity, loadFactor);
|
||||
this.dbTrueValue = dbTrueValue;
|
||||
this.optimizedBinaryUUID = optimizedBinaryUUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,7 +95,7 @@ public class DefaultSqlRow implements SqlRow {
|
||||
|
||||
@Override
|
||||
public UUID getUUID(String name) {
|
||||
return BasicTypeConverter.toUUID(get(name));
|
||||
return BasicTypeConverter.toUUID(get(name), optimizedBinaryUUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,9 +2,13 @@ package io.ebeaninternal.server.rawsql;
|
||||
|
||||
import io.ebean.RawSql;
|
||||
import io.ebean.RawSqlBuilder;
|
||||
import io.ebean.SqlRow;
|
||||
import io.ebean.service.SpiRawSqlService;
|
||||
import io.ebeaninternal.server.query.DefaultSqlRow;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class DRawSqlService implements SpiRawSqlService {
|
||||
|
||||
@@ -28,4 +32,20 @@ public class DRawSqlService implements SpiRawSqlService {
|
||||
SpiRawSql.Sql s = new SpiRawSql.Sql(sql);
|
||||
return new DRawSqlBuilder(s, new SpiRawSql.ColumnMapping());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlRow sqlRow(ResultSet resultSet, String dbTrueValue) throws SQLException {
|
||||
ResultSetMetaData meta = resultSet.getMetaData();
|
||||
int estCap = (int) (meta.getColumnCount() / 0.7f) + 1;
|
||||
DefaultSqlRow ret = new DefaultSqlRow(estCap, 0.75f, dbTrueValue, false);
|
||||
|
||||
for (int i = 1; i <= meta.getColumnCount(); i++) {
|
||||
String name = meta.getColumnLabel(i);
|
||||
if (name == null) {
|
||||
name = meta.getColumnName(i);
|
||||
}
|
||||
ret.put(name, resultSet.getObject(i));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -931,7 +931,7 @@ public final class DefaultTypeManager implements TypeManager {
|
||||
typeMap.put(UUID.class, new ScalarTypeUUIDNative());
|
||||
} else {
|
||||
// Store UUID as binary(16) or varchar(40)
|
||||
ScalarType<?> uuidType = dbUuid.useBinary() ? new ScalarTypeUUIDBinary() : new ScalarTypeUUIDVarchar();
|
||||
ScalarType<?> uuidType = dbUuid.useBinary() ? new ScalarTypeUUIDBinary(dbUuid.useBinaryOptimized()) : new ScalarTypeUUIDVarchar();
|
||||
typeMap.put(UUID.class, uuidType);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,11 +70,12 @@ public class ScalarTypeJsonList {
|
||||
|
||||
@Override
|
||||
public List read(DataReader dataReader) throws SQLException {
|
||||
String json = dataReader.getString();
|
||||
try {
|
||||
// parse JSON into modifyAware list
|
||||
return EJson.parseList(dataReader.getString(), true);
|
||||
return EJson.parseList(json, true);
|
||||
} catch (IOException e) {
|
||||
throw new SQLException("Failed to parse JSON content as List: [" + dataReader.getString() + "]", e);
|
||||
throw new SQLException("Failed to parse JSON content as List: [" + json + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,11 +73,12 @@ public class ScalarTypeJsonSet {
|
||||
|
||||
@Override
|
||||
public Set read(DataReader dataReader) throws SQLException {
|
||||
String json = dataReader.getString();
|
||||
try {
|
||||
// parse JSON into modifyAware list
|
||||
return EJson.parseSet(dataReader.getString(), true);
|
||||
return EJson.parseSet(json, true);
|
||||
} catch (IOException e) {
|
||||
throw new SQLException("Failed to parse JSON content as List: [" + dataReader.getString() + "]", e);
|
||||
throw new SQLException("Failed to parse JSON content as List: [" + json + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class ScalarTypeUUIDBase extends ScalarTypeBase<UUID> implements
|
||||
|
||||
@Override
|
||||
public UUID toBeanType(Object value) {
|
||||
return BasicTypeConverter.toUUID(value);
|
||||
return BasicTypeConverter.toUUID(value, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,19 +2,18 @@ package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebeaninternal.server.core.BasicTypeConverter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ScalarTypeUUIDBinary extends ScalarTypeUUIDBase {
|
||||
|
||||
protected ScalarTypeUUIDBinary() {
|
||||
private final boolean optimized;
|
||||
|
||||
|
||||
protected ScalarTypeUUIDBinary(boolean optimized) {
|
||||
super(false, Types.BINARY);
|
||||
this.optimized = optimized;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -24,15 +23,15 @@ public class ScalarTypeUUIDBinary extends ScalarTypeUUIDBase {
|
||||
|
||||
@Override
|
||||
public Object toJdbcType(Object value) {
|
||||
return convertToBytes(value);
|
||||
return convertToBytes(value, optimized);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID toBeanType(Object value) {
|
||||
if (value instanceof byte[]) {
|
||||
return convertFromBytes((byte[]) value);
|
||||
return convertFromBytes((byte[]) value, optimized);
|
||||
} else {
|
||||
return BasicTypeConverter.toUUID(value);
|
||||
return BasicTypeConverter.toUUID(value, optimized);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +40,7 @@ public class ScalarTypeUUIDBinary extends ScalarTypeUUIDBase {
|
||||
if (value == null) {
|
||||
b.setNull(Types.BINARY);
|
||||
} else {
|
||||
b.setBytes(convertToBytes(value));
|
||||
b.setBytes(convertToBytes(value, optimized));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,14 +50,14 @@ public class ScalarTypeUUIDBinary extends ScalarTypeUUIDBase {
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
} else {
|
||||
return convertFromBytes(bytes);
|
||||
return convertFromBytes(bytes, optimized);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from byte[] to UUID.
|
||||
*/
|
||||
public static UUID convertFromBytes(byte[] bytes) {
|
||||
public static UUID convertFromBytes(byte[] bytes, boolean optimized) {
|
||||
|
||||
int usableBytes = Math.min(bytes.length, 16);
|
||||
|
||||
@@ -70,36 +69,80 @@ public class ScalarTypeUUIDBinary extends ScalarTypeUUIDBase {
|
||||
barr[i] = bytes[j];
|
||||
}
|
||||
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(barr);
|
||||
DataInputStream inputStream = new DataInputStream(bais);
|
||||
|
||||
try {
|
||||
long msb = inputStream.readLong();
|
||||
long lsb = inputStream.readLong();
|
||||
return new UUID(msb, lsb);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Not Expecting this", e);
|
||||
long msb;
|
||||
if (optimized) {
|
||||
msb = ((long)barr[4] << 56) + // XXXXXXXX-____-____-...
|
||||
((long)(barr[5] & 255) << 48) + // -> put at end 4..7 of buf
|
||||
((long)(barr[6] & 255) << 40) +
|
||||
((long)(barr[7] & 255) << 32) +
|
||||
((long)(barr[2] & 255) << 24) + // ________-XXXX-____-...
|
||||
((barr[3] & 255) << 16) + // put at 2..3 in buf
|
||||
((barr[0] & 255) << 8) + // ________-____-XXXX-...
|
||||
((barr[1] & 255) << 0); // put at 0..1 in buf
|
||||
} else {
|
||||
msb = ((long)barr[0] << 56) + // XXXXXXXX-____-____-...
|
||||
((long)(barr[1] & 255) << 48) +
|
||||
((long)(barr[2] & 255) << 40) +
|
||||
((long)(barr[3] & 255) << 32) +
|
||||
((long)(barr[4] & 255) << 24) + // ________-XXXX-____-...
|
||||
((barr[5] & 255) << 16) +
|
||||
((barr[6] & 255) << 8) + // ________-____-XXXX-...
|
||||
((barr[7] & 255) << 0);
|
||||
}
|
||||
long lsb = ((long)barr[8] << 56) +
|
||||
((long)(barr[9] & 255) << 48) +
|
||||
((long)(barr[10] & 255) << 40) +
|
||||
((long)(barr[11] & 255) << 32) +
|
||||
((long)(barr[12] & 255) << 24) +
|
||||
((barr[13] & 255) << 16) +
|
||||
((barr[14] & 255) << 8) +
|
||||
((barr[15] & 255) << 0);
|
||||
|
||||
return new UUID(msb, lsb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from UUID to byte[].
|
||||
*/
|
||||
public static byte[] convertToBytes(Object value) {
|
||||
public static byte[] convertToBytes(Object value, boolean optimized) {
|
||||
|
||||
|
||||
UUID uuid = (UUID) value;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(16);
|
||||
DataOutputStream outputStream = new DataOutputStream(baos);
|
||||
byte[] ret = new byte[16];
|
||||
long l = uuid.getMostSignificantBits();
|
||||
|
||||
try {
|
||||
outputStream.writeLong(uuid.getMostSignificantBits());
|
||||
outputStream.writeLong(uuid.getLeastSignificantBits());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Not Expecting this", e);
|
||||
if (optimized) {
|
||||
ret[0] = (byte) (l >>> 8); // was 6/7
|
||||
ret[1] = (byte) (l >>> 0);
|
||||
|
||||
ret[2] = (byte) (l >>> 24); // was 4/5
|
||||
ret[3] = (byte) (l >>> 16);
|
||||
|
||||
ret[4] = (byte) (l >>> 56); // was 0..3
|
||||
ret[5] = (byte) (l >>> 48);
|
||||
ret[6] = (byte) (l >>> 40);
|
||||
ret[7] = (byte) (l >>> 32);
|
||||
} else {
|
||||
ret[0] = (byte) (l >>> 56);
|
||||
ret[1] = (byte) (l >>> 48);
|
||||
ret[2] = (byte) (l >>> 40);
|
||||
ret[3] = (byte) (l >>> 32);
|
||||
ret[4] = (byte) (l >>> 24);
|
||||
ret[5] = (byte) (l >>> 16);
|
||||
ret[6] = (byte) (l >>> 8);
|
||||
ret[7] = (byte) (l >>> 0);
|
||||
}
|
||||
l = uuid.getLeastSignificantBits();
|
||||
ret[8] = (byte) (l >>> 56);
|
||||
ret[9] = (byte) (l >>> 48);
|
||||
ret[10] = (byte) (l >>> 40);
|
||||
ret[11] = (byte) (l >>> 32);
|
||||
ret[12] = (byte) (l >>> 24);
|
||||
ret[13] = (byte) (l >>> 16);
|
||||
ret[14] = (byte) (l >>> 8);
|
||||
ret[15] = (byte) (l >>> 0);
|
||||
|
||||
return baos.toByteArray();
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Licensed Materials - Property of FOCONIS AG
|
||||
* (C) Copyright FOCONIS AG.
|
||||
*/
|
||||
|
||||
package io.ebeaninternal.server.idgen;
|
||||
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import io.ebean.config.dbplatform.PlatformIdGenerator;
|
||||
|
||||
|
||||
/**
|
||||
* Run some simple tests for the UUID generator.
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*
|
||||
*/
|
||||
public class TestUuidGenerator {
|
||||
|
||||
|
||||
/**
|
||||
* Worker to generate UUIDs
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*
|
||||
*/
|
||||
public static class IdTest implements Runnable {
|
||||
private final Map<UUID, UUID> map;
|
||||
private final PlatformIdGenerator idGen;
|
||||
private final int ids;
|
||||
private final AtomicBoolean failFlag;
|
||||
|
||||
public IdTest(PlatformIdGenerator idGen, int ids, Map<UUID, UUID> map, AtomicBoolean failFlag) {
|
||||
this.idGen = idGen;
|
||||
this.ids = ids;
|
||||
this.map = map;
|
||||
this.failFlag = failFlag;
|
||||
}
|
||||
|
||||
public IdTest(PlatformIdGenerator idGen, int ids) {
|
||||
this.idGen = idGen;
|
||||
this.ids = ids;
|
||||
this.map = null;
|
||||
this.failFlag = null;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
//System.out.println("Start " + Thread.currentThread());
|
||||
for (int i = 0; i < ids; i++) {
|
||||
UUID uuid = (UUID) idGen.nextId(null);
|
||||
if (map != null && map.put(uuid, uuid) != null) {
|
||||
System.err.println("UUID already in set " + uuid);
|
||||
failFlag.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test takes ~0.3 sec
|
||||
*/
|
||||
@Test
|
||||
public void testUuidV1SingleThread() throws Exception {
|
||||
testGenerator(1, 1_000_000, UuidV1IdGenerator.getInstance("ebean-test-uuid.state"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test takes ~1.4 sec
|
||||
*/
|
||||
@Test
|
||||
public void testUuidV1MultiThread() throws Exception {
|
||||
testGenerator(10, 100_000, UuidV1IdGenerator.getInstance("ebean-test-uuid.state"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test takes ~3.1 sec
|
||||
*/
|
||||
@Test
|
||||
public void testUuidV1RndMultiThread() throws Exception {
|
||||
testGenerator(10, 100_000, UuidV1RndIdGenerator.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test takes ~2.0 sec
|
||||
*/
|
||||
@Test
|
||||
public void testUuidType1RndSingleThread() throws Exception {
|
||||
testGenerator(1, 1_000_000, UuidV1RndIdGenerator.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test takes ~4.9 sec
|
||||
*/
|
||||
@Test
|
||||
public void testUuidType4MultiThread() throws Exception {
|
||||
testGenerator(10, 100_000, UuidV4IdGenerator.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test takes ~3.1 sec
|
||||
*/
|
||||
@Test
|
||||
public void testUuidType4SingleThread() throws Exception {
|
||||
testGenerator(1, 1_000_000, UuidV4IdGenerator.INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void testGenerator(int threadCount, int count, PlatformIdGenerator generator) throws Exception {
|
||||
System.out.println("Printing 5 consecutive IDs of " + generator);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
System.out.println(generator.nextId(null));
|
||||
}
|
||||
|
||||
AtomicBoolean failFlag = new AtomicBoolean();
|
||||
ConcurrentHashMap<UUID, UUID> map = new ConcurrentHashMap<>();
|
||||
Thread[] threads = new Thread[threadCount];
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
threads[i] = new Thread(new IdTest(generator, count, map, failFlag));
|
||||
}
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
threads[i].start();
|
||||
}
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
threads[i].join();
|
||||
}
|
||||
assertThat(failFlag.get()).isFalse();
|
||||
assertThat(map.size()).isEqualTo(threadCount * count);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public class DefaultSqlRowTest {
|
||||
@Test
|
||||
public void test_keyConversion() {
|
||||
|
||||
DefaultSqlRow row = new DefaultSqlRow(16, 0.5f, "T");
|
||||
DefaultSqlRow row = new DefaultSqlRow(16, 0.5f, "T", false);
|
||||
row.put("Foo", "hello");
|
||||
|
||||
assertThat(row.containsKey("foo")).isTrue();
|
||||
|
||||
@@ -12,10 +12,22 @@ public class TestScalarTypeUUIDBinaryConversion {
|
||||
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
byte[] bytes = ScalarTypeUUIDBinary.convertToBytes(id);
|
||||
byte[] bytes = ScalarTypeUUIDBinary.convertToBytes(id, false);
|
||||
Assert.assertEquals(16, bytes.length);
|
||||
|
||||
UUID id2 = ScalarTypeUUIDBinary.convertFromBytes(bytes);
|
||||
UUID id2 = ScalarTypeUUIDBinary.convertFromBytes(bytes, false);
|
||||
Assert.assertEquals(id, id2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConversionOptimized() {
|
||||
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
byte[] bytes = ScalarTypeUUIDBinary.convertToBytes(id, true);
|
||||
Assert.assertEquals(16, bytes.length);
|
||||
|
||||
UUID id2 = ScalarTypeUUIDBinary.convertFromBytes(bytes, true);
|
||||
Assert.assertEquals(id, id2);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_assoc")
|
||||
public class CKeyAssoc {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String assocOne;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAssocOne() {
|
||||
return assocOne;
|
||||
}
|
||||
|
||||
public void setAssocOne(String assocOne) {
|
||||
this.assocOne = assocOne;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_detail")
|
||||
public class CKeyDetail {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String something;
|
||||
|
||||
|
||||
public CKeyDetail() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyDetail(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_parent")
|
||||
public class CKeyParent {
|
||||
|
||||
@EmbeddedId
|
||||
CKeyParentId id;
|
||||
|
||||
String name;
|
||||
|
||||
@Version
|
||||
int version;
|
||||
|
||||
public CKeyParentId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(CKeyParentId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Embeddable
|
||||
public class CKeyParentId {
|
||||
|
||||
@Size(max=127)
|
||||
Integer oneKey;
|
||||
|
||||
@Size(max=127)
|
||||
String twoKey;
|
||||
|
||||
public CKeyParentId() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyParentId(Integer oneKey, String twoKey) {
|
||||
this.oneKey = oneKey;
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
public Integer getOneKey() {
|
||||
return oneKey;
|
||||
}
|
||||
|
||||
public void setOneKey(Integer oneKey) {
|
||||
this.oneKey = oneKey;
|
||||
}
|
||||
|
||||
public String getTwoKey() {
|
||||
return twoKey;
|
||||
}
|
||||
|
||||
public void setTwoKey(String twoKey) {
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof CKeyParentId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CKeyParentId otherKey = (CKeyParentId) o;
|
||||
return otherKey.hashCode() == hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = getClass().getName().hashCode();
|
||||
hc = 31 * hc + oneKey;
|
||||
hc = 31 * hc + twoKey.hashCode();
|
||||
return hc;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,10 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_ref")
|
||||
@@ -16,4 +20,9 @@ public class ERef {
|
||||
|
||||
@OneToMany
|
||||
List<EBasic> basics;
|
||||
|
||||
@NotNull
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String name;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_c")
|
||||
public class MtmChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_m")
|
||||
public class MtmMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_child")
|
||||
public class OtoChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_master")
|
||||
public class OtoMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_assoc")
|
||||
public class CKeyAssoc {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String assocOne;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAssocOne() {
|
||||
return assocOne;
|
||||
}
|
||||
|
||||
public void setAssocOne(String assocOne) {
|
||||
this.assocOne = assocOne;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_detail")
|
||||
public class CKeyDetail {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String something;
|
||||
|
||||
@ManyToOne
|
||||
// @JoinColumns({
|
||||
// @JoinColumn(name="parent_one_key", referencedColumnName="one_key"),
|
||||
// @JoinColumn(name="parent_two_key", referencedColumnName="two_key")
|
||||
// })
|
||||
CKeyParent parent;
|
||||
|
||||
public CKeyDetail() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyDetail(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public CKeyParent getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(CKeyParent parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_parent")
|
||||
public class CKeyParent {
|
||||
|
||||
@EmbeddedId
|
||||
CKeyParentId id;
|
||||
|
||||
String name;
|
||||
|
||||
@Version
|
||||
int version;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.PERSIST)
|
||||
CKeyAssoc assoc;
|
||||
|
||||
@OneToMany(cascade = CascadeType.PERSIST, mappedBy = "parent")
|
||||
List<CKeyDetail> details;
|
||||
|
||||
public CKeyParentId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(CKeyParentId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public CKeyAssoc getAssoc() {
|
||||
return assoc;
|
||||
}
|
||||
|
||||
public void setAssoc(CKeyAssoc assoc) {
|
||||
this.assoc = assoc;
|
||||
}
|
||||
|
||||
public List<CKeyDetail> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(List<CKeyDetail> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public void add(CKeyDetail detail) {
|
||||
if (details == null) {
|
||||
details = new ArrayList<>();
|
||||
}
|
||||
details.add(detail);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Embeddable
|
||||
public class CKeyParentId {
|
||||
|
||||
@Size(max=127)
|
||||
Integer oneKey;
|
||||
|
||||
@Size(max=127)
|
||||
String twoKey;
|
||||
|
||||
public CKeyParentId() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyParentId(Integer oneKey, String twoKey) {
|
||||
this.oneKey = oneKey;
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
public Integer getOneKey() {
|
||||
return oneKey;
|
||||
}
|
||||
|
||||
public void setOneKey(Integer oneKey) {
|
||||
this.oneKey = oneKey;
|
||||
}
|
||||
|
||||
public String getTwoKey() {
|
||||
return twoKey;
|
||||
}
|
||||
|
||||
public void setTwoKey(String twoKey) {
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof CKeyParentId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CKeyParentId otherKey = (CKeyParentId) o;
|
||||
return otherKey.hashCode() == hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = getClass().getName().hashCode();
|
||||
hc = 31 * hc + oneKey;
|
||||
hc = 31 * hc + twoKey.hashCode();
|
||||
return hc;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_basic")
|
||||
@Index(columnNames = { "status" , "indextest1"}, unique = true)
|
||||
public class EBasic {
|
||||
|
||||
public enum Status {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_c")
|
||||
public class MtmChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
@ManyToMany
|
||||
List<MtmMaster> masters;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<MtmMaster> getMasters() {
|
||||
return masters;
|
||||
}
|
||||
|
||||
public void setMasters(List<MtmMaster> masters) {
|
||||
this.masters = masters;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_m")
|
||||
public class MtmMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@ManyToMany
|
||||
List<MtmChild> children;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<MtmChild> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<MtmChild> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_child")
|
||||
public class OtoChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToOne
|
||||
OtoMaster master;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public OtoMaster getMaster() {
|
||||
return master;
|
||||
}
|
||||
|
||||
public void setMaster(OtoMaster master) {
|
||||
this.master = master;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_master")
|
||||
public class OtoMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL, mappedBy = "master")
|
||||
OtoChild child;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public OtoChild getChild() {
|
||||
return child;
|
||||
}
|
||||
|
||||
public void setChild(OtoChild child) {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_assoc")
|
||||
public class CKeyAssoc {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String assocOne;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAssocOne() {
|
||||
return assocOne;
|
||||
}
|
||||
|
||||
public void setAssocOne(String assocOne) {
|
||||
this.assocOne = assocOne;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_detail")
|
||||
public class CKeyDetail {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String something;
|
||||
|
||||
|
||||
public CKeyDetail() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyDetail(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_parent")
|
||||
public class CKeyParent {
|
||||
|
||||
@EmbeddedId
|
||||
CKeyParentId id;
|
||||
|
||||
String name;
|
||||
|
||||
@Version
|
||||
int version;
|
||||
|
||||
public CKeyParentId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(CKeyParentId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Embeddable
|
||||
public class CKeyParentId {
|
||||
|
||||
@Size(max=127)
|
||||
Integer oneKey;
|
||||
|
||||
@Size(max=127)
|
||||
String twoKey;
|
||||
|
||||
public CKeyParentId() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyParentId(Integer oneKey, String twoKey) {
|
||||
this.oneKey = oneKey;
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
public Integer getOneKey() {
|
||||
return oneKey;
|
||||
}
|
||||
|
||||
public void setOneKey(Integer oneKey) {
|
||||
this.oneKey = oneKey;
|
||||
}
|
||||
|
||||
public String getTwoKey() {
|
||||
return twoKey;
|
||||
}
|
||||
|
||||
public void setTwoKey(String twoKey) {
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof CKeyParentId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CKeyParentId otherKey = (CKeyParentId) o;
|
||||
return otherKey.hashCode() == hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = getClass().getName().hashCode();
|
||||
hc = 31 * hc + oneKey;
|
||||
hc = 31 * hc + twoKey.hashCode();
|
||||
return hc;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,10 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_ref")
|
||||
@@ -16,4 +20,9 @@ public class ERef {
|
||||
|
||||
@OneToMany
|
||||
List<EBasic> basics;
|
||||
|
||||
@NotNull
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String name;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_c")
|
||||
public class MtmChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_m")
|
||||
public class MtmMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_child")
|
||||
public class OtoChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_master")
|
||||
public class OtoMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,25 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer generated by default as identity not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer generated by default as identity not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
@@ -70,8 +90,10 @@ create table migtest_e_history2 (
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name);
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id integer generated by default as identity not null,
|
||||
@@ -79,6 +101,30 @@ create table migtest_e_softdelete (
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigint generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigint generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_mgtst__b_eu8csq on migtest_e_basic (indextest1);
|
||||
create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5);
|
||||
alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
|
||||
@@ -5,6 +5,24 @@ create table migtest_e_user (
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer;
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_mgtst_ck_e1qkb5 foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l;
|
||||
alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict;
|
||||
alter table migtest_fk_none add constraint fk_mgtst_fk_nn_n_d foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
@@ -39,6 +57,7 @@ alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4aybzy;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc02;
|
||||
-- NOT SUPPORTED alter table migtest_e_basic add constraint uq_mgtst__b_ucfcne unique (status,indextest1);
|
||||
-- NOT SUPPORTED alter table migtest_e_basic add constraint uq_mgtst__bsc_nm unique (name);
|
||||
-- NOT SUPPORTED alter table migtest_e_basic add constraint uq_mgtst__b_4ayc00 unique (indextest4);
|
||||
-- NOT SUPPORTED alter table migtest_e_basic add constraint uq_mgtst__b_4ayc01 unique (indextest5);
|
||||
@@ -56,7 +75,26 @@ alter table migtest_e_history2_history add column test_string3 varchar(255);
|
||||
|
||||
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index ix_mgtst__b_eu8css on migtest_e_basic (indextest3);
|
||||
create index ix_mgtst__b_eu8csv on migtest_e_basic (indextest6);
|
||||
drop index ix_mgtst__b_eu8csq;
|
||||
drop index ix_mgtst__b_eu8csu;
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mt_93awga foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict;
|
||||
create index ix_mgtst_mt_3ug4ok on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mt_93awgk foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
create index ix_mgtst_mt_3ug4ou on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mt_ggi34k foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
create index ix_mgtst_mt_b7nbcu on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mt_ggi34a foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict;
|
||||
create index ix_mgtst_mt_b7nbck on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_ckey_parent add constraint fk_mgtst_ck_da00mr foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict;
|
||||
create index ix_mgtst_ck_x45o21 on migtest_ckey_parent (assoc_id);
|
||||
|
||||
alter table migtest_oto_child add constraint fk_mgtst_t__csyl38 foreign key (master_id) references migtest_oto_master (id) on delete restrict;
|
||||
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name);
|
||||
|
||||
alter table migtest_ckey_detail drop constraint fk_mgtst_ck_e1qkb5;
|
||||
alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l;
|
||||
alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
alter table migtest_fk_none drop constraint fk_mgtst_fk_nn_n_d;
|
||||
@@ -27,6 +30,7 @@ alter table migtest_e_basic add column old_boolean boolean default false not nul
|
||||
alter table migtest_e_basic add column old_boolean2 boolean;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_ucfcne;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__bsc_nm;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc00;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc01;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
@@ -18,5 +24,9 @@ alter table migtest_e_history2_history drop column test_string3;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table migtest_e_user;
|
||||
drop sequence migtest_e_user_seq;
|
||||
drop table migtest_mtm_c_migtest_mtm_m;
|
||||
drop table migtest_mtm_m_migtest_mtm_c;
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer auto_increment not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer auto_increment not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer(127) not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigint auto_increment not null,
|
||||
one_id bigint,
|
||||
@@ -70,6 +90,8 @@ create table migtest_e_history2 (
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer auto_increment not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
@@ -79,6 +101,30 @@ create table migtest_e_softdelete (
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigint auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigint auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
||||
|
||||
@@ -5,6 +5,24 @@ create table migtest_e_user (
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer(127);
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
||||
@@ -39,6 +57,7 @@ alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
|
||||
@@ -56,10 +75,29 @@ alter table migtest_e_history2_history add column test_string3 varchar(255);
|
||||
|
||||
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
drop index if exists ix_migtest_e_basic_indextest1;
|
||||
drop index if exists ix_migtest_e_basic_indextest5;
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
|
||||
|
||||
alter table migtest_e_history add column sys_period_start datetime(6) default now(6);
|
||||
alter table migtest_e_history add column sys_period_end datetime(6);
|
||||
create table migtest_e_history_history(
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer auto_increment not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent;
|
||||
alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
||||
alter table migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id;
|
||||
@@ -27,6 +30,7 @@ alter table migtest_e_basic add column old_boolean boolean default false not nul
|
||||
alter table migtest_e_basic add column old_boolean2 boolean;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
||||
|
||||
@@ -8,6 +8,12 @@ drop table migtest_e_history_history;
|
||||
|
||||
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
@@ -26,8 +32,12 @@ alter table migtest_e_history2_history drop column test_string3;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table if exists migtest_e_user;
|
||||
drop sequence if exists migtest_e_user_seq;
|
||||
drop table if exists migtest_mtm_c_migtest_mtm_m;
|
||||
drop table if exists migtest_mtm_m_migtest_mtm_c;
|
||||
-- changes: [drop test_string2, drop test_string3]
|
||||
drop trigger migtest_e_history2_history_upd;
|
||||
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer generated by default as identity (start with 1) not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer generated by default as identity (start with 1) not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigint generated by default as identity (start with 1) not null,
|
||||
one_id bigint,
|
||||
@@ -70,6 +90,8 @@ create table migtest_e_history2 (
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity (start with 1) not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
@@ -79,6 +101,30 @@ create table migtest_e_softdelete (
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer generated by default as identity (start with 1) not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigint generated by default as identity (start with 1) not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer generated by default as identity (start with 1) not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigint generated by default as identity (start with 1) not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
||||
|
||||
@@ -5,6 +5,24 @@ create table migtest_e_user (
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer;
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
||||
@@ -39,6 +57,7 @@ alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
|
||||
@@ -56,7 +75,26 @@ alter table migtest_e_history2_history add column test_string3 varchar(255);
|
||||
|
||||
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
drop index if exists ix_migtest_e_basic_indextest1;
|
||||
drop index if exists ix_migtest_e_basic_indextest5;
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
|
||||
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity (start with 1) not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent;
|
||||
alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
||||
alter table migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id;
|
||||
@@ -27,6 +30,7 @@ alter table migtest_e_basic add column old_boolean boolean default false not nul
|
||||
alter table migtest_e_basic add column old_boolean2 boolean;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
@@ -18,5 +24,9 @@ alter table migtest_e_history2_history drop column test_string3;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table if exists migtest_e_user;
|
||||
drop sequence if exists migtest_e_user_seq;
|
||||
drop table if exists migtest_mtm_c_migtest_mtm_m;
|
||||
drop table if exists migtest_mtm_m_migtest_mtm_c;
|
||||
|
||||
@@ -2,6 +2,20 @@
|
||||
<!DOCTYPE xml>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply">
|
||||
<createTable name="migtest_ckey_assoc" pkName="pk_migtest_ckey_assoc">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="assoc_one" type="varchar"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_ckey_detail" pkName="pk_migtest_ckey_detail">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="something" type="varchar"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_ckey_parent" pkName="pk_migtest_ckey_parent">
|
||||
<column name="one_key" type="integer(127)" primaryKey="true"/>
|
||||
<column name="two_key" type="varchar(127)" primaryKey="true"/>
|
||||
<column name="name" type="varchar"/>
|
||||
<column name="version" type="integer" notnull="true"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_fk_cascade" pkName="pk_migtest_fk_cascade">
|
||||
<column name="id" type="bigint" primaryKey="true"/>
|
||||
<column name="one_id" type="bigint" references="migtest_fk_cascade_one.id" foreignKeyName="fk_migtest_fk_cascade_one_id" foreignKeyIndex="ix_migtest_fk_cascade_one_id" foreignKeyOnDelete="CASCADE" foreignKeyOnUpdate="RESTRICT"/>
|
||||
@@ -53,11 +67,29 @@
|
||||
</createTable>
|
||||
<createTable name="migtest_e_ref" pkName="pk_migtest_e_ref">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="name" type="varchar(127)" notnull="true"/>
|
||||
<uniqueConstraint name="uq_migtest_e_ref_name" columnNames="name" oneToOne="false" nullableColumns=""/>
|
||||
</createTable>
|
||||
<createTable name="migtest_e_softdelete" pkName="pk_migtest_e_softdelete">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="test_string" type="varchar"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_mtm_c" pkName="pk_migtest_mtm_c">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="name" type="varchar"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_mtm_m" pkName="pk_migtest_mtm_m">
|
||||
<column name="id" type="bigint" primaryKey="true"/>
|
||||
<column name="name" type="varchar"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_oto_child" pkName="pk_migtest_oto_child">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="name" type="varchar"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_oto_master" pkName="pk_migtest_oto_master">
|
||||
<column name="id" type="bigint" primaryKey="true"/>
|
||||
<column name="name" type="varchar"/>
|
||||
</createTable>
|
||||
<createIndex indexName="ix_migtest_e_basic_indextest1" tableName="migtest_e_basic" columns="indextest1"/>
|
||||
<createIndex indexName="ix_migtest_e_basic_indextest5" tableName="migtest_e_basic" columns="indextest5"/>
|
||||
</changeSet>
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
<!DOCTYPE xml>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply">
|
||||
<addColumn tableName="migtest_ckey_detail">
|
||||
<column name="one_key" type="integer(127)"/>
|
||||
<column name="two_key" type="varchar(127)"/>
|
||||
</addColumn>
|
||||
<alterForeignKey name="fk_migtest_ckey_detail_parent" columnNames="one_key,two_key" refColumnNames="one_key,two_key" refTableName="migtest_ckey_parent" indexName="ix_migtest_ckey_detail_parent" tableName="migtest_ckey_detail"/>
|
||||
<addColumn tableName="migtest_ckey_parent">
|
||||
<column name="assoc_id" type="integer" references="migtest_ckey_assoc.id" foreignKeyName="fk_migtest_ckey_parent_assoc_id" foreignKeyIndex="ix_migtest_ckey_parent_assoc_id"/>
|
||||
</addColumn>
|
||||
<alterColumn columnName="one_id" tableName="migtest_fk_cascade" references="migtest_fk_cascade_one.id" foreignKeyName="fk_migtest_fk_cascade_one_id" foreignKeyIndex="ix_migtest_fk_cascade_one_id" foreignKeyOnDelete="RESTRICT" foreignKeyOnUpdate="RESTRICT" dropForeignKey="fk_migtest_fk_cascade_one_id" dropForeignKeyIndex="ix_migtest_fk_cascade_one_id"/>
|
||||
<alterColumn columnName="one_id" tableName="migtest_fk_none" references="migtest_fk_one.id" foreignKeyName="fk_migtest_fk_none_one_id" foreignKeyIndex="ix_migtest_fk_none_one_id" foreignKeyOnDelete="RESTRICT" foreignKeyOnUpdate="RESTRICT"/>
|
||||
<alterColumn columnName="one_id" tableName="migtest_fk_none_via_join" references="migtest_fk_one.id" foreignKeyName="fk_migtest_fk_none_via_join_one_id" foreignKeyIndex="ix_migtest_fk_none_via_join_one_id"/>
|
||||
@@ -25,6 +33,7 @@
|
||||
</addColumn>
|
||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest2" tableName="migtest_e_basic" columnNames="DROP CONSTRAINT" nullableColumns="indextest2"/>
|
||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest6" tableName="migtest_e_basic" columnNames="DROP CONSTRAINT" nullableColumns="indextest6"/>
|
||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_status_indextest1" tableName="migtest_e_basic" columnNames="status,indextest1" nullableColumns="indextest1" oneToOne="false"/>
|
||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_name" tableName="migtest_e_basic" columnNames="name" nullableColumns="name" oneToOne="false"/>
|
||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest4" tableName="migtest_e_basic" columnNames="indextest4" nullableColumns="indextest4" oneToOne="false"/>
|
||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest5" tableName="migtest_e_basic" columnNames="indextest5" nullableColumns="indextest5" oneToOne="false"/>
|
||||
@@ -44,6 +53,21 @@
|
||||
<createTable name="migtest_e_user" pkName="pk_migtest_e_user">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_mtm_c_migtest_mtm_m" pkName="pk_migtest_mtm_c_migtest_mtm_m">
|
||||
<column name="migtest_mtm_c_id" type="integer" notnull="true" primaryKey="true"/>
|
||||
<column name="migtest_mtm_m_id" type="bigint" notnull="true" primaryKey="true"/>
|
||||
<foreignKey name="fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c" columnNames="migtest_mtm_c_id" refColumnNames="id" refTableName="migtest_mtm_c" indexName="ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c"/>
|
||||
<foreignKey name="fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m" columnNames="migtest_mtm_m_id" refColumnNames="id" refTableName="migtest_mtm_m" indexName="ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_mtm_m_migtest_mtm_c" pkName="pk_migtest_mtm_m_migtest_mtm_c">
|
||||
<column name="migtest_mtm_m_id" type="bigint" notnull="true" primaryKey="true"/>
|
||||
<column name="migtest_mtm_c_id" type="integer" notnull="true" primaryKey="true"/>
|
||||
<foreignKey name="fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m" columnNames="migtest_mtm_m_id" refColumnNames="id" refTableName="migtest_mtm_m" indexName="ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m"/>
|
||||
<foreignKey name="fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c" columnNames="migtest_mtm_c_id" refColumnNames="id" refTableName="migtest_mtm_c" indexName="ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c"/>
|
||||
</createTable>
|
||||
<addColumn tableName="migtest_oto_child">
|
||||
<column name="master_id" type="bigint" uniqueOneToOne="uq_migtest_oto_child_master_id" references="migtest_oto_master.id" foreignKeyName="fk_migtest_oto_child_master_id"/>
|
||||
</addColumn>
|
||||
<createIndex indexName="ix_migtest_e_basic_indextest3" tableName="migtest_e_basic" columns="indextest3"/>
|
||||
<createIndex indexName="ix_migtest_e_basic_indextest6" tableName="migtest_e_basic" columns="indextest6"/>
|
||||
<dropIndex indexName="ix_migtest_e_basic_indextest1" tableName="migtest_e_basic"/>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<!DOCTYPE xml>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply">
|
||||
<alterForeignKey name="fk_migtest_ckey_detail_parent" columnNames="DROP FOREIGN KEY" indexName="ix_migtest_ckey_detail_parent" tableName="migtest_ckey_detail"/>
|
||||
<alterColumn columnName="one_id" tableName="migtest_fk_cascade" references="migtest_fk_cascade_one.id" foreignKeyName="fk_migtest_fk_cascade_one_id" foreignKeyIndex="ix_migtest_fk_cascade_one_id" foreignKeyOnDelete="CASCADE" foreignKeyOnUpdate="RESTRICT" dropForeignKey="fk_migtest_fk_cascade_one_id" dropForeignKeyIndex="ix_migtest_fk_cascade_one_id"/>
|
||||
<alterColumn columnName="one_id" tableName="migtest_fk_none" dropForeignKey="fk_migtest_fk_none_one_id" dropForeignKeyIndex="ix_migtest_fk_none_one_id"/>
|
||||
<alterColumn columnName="one_id" tableName="migtest_fk_none_via_join" dropForeignKey="fk_migtest_fk_none_via_join_one_id" dropForeignKeyIndex="ix_migtest_fk_none_via_join_one_id"/>
|
||||
@@ -15,6 +16,7 @@
|
||||
<column name="old_boolean2" type="boolean"/>
|
||||
<column name="eref_id" type="integer" references="migtest_e_ref.id" foreignKeyName="fk_migtest_e_basic_eref_id" foreignKeyIndex="ix_migtest_e_basic_eref_id"/>
|
||||
</addColumn>
|
||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_status_indextest1" tableName="migtest_e_basic" columnNames="DROP CONSTRAINT" nullableColumns="indextest1"/>
|
||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_name" tableName="migtest_e_basic" columnNames="DROP CONSTRAINT" nullableColumns="name"/>
|
||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest4" tableName="migtest_e_basic" columnNames="DROP CONSTRAINT" nullableColumns="indextest4"/>
|
||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest5" tableName="migtest_e_basic" columnNames="DROP CONSTRAINT" nullableColumns="indextest5"/>
|
||||
@@ -25,6 +27,8 @@
|
||||
<alterColumn columnName="test_string" tableName="migtest_e_history2" withHistory="true" currentType="varchar" defaultValue="DROP DEFAULT" notnull="false" currentNotnull="true"/>
|
||||
<createTable name="migtest_e_ref" pkName="pk_migtest_e_ref">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="name" type="varchar(127)" notnull="true"/>
|
||||
<uniqueConstraint name="uq_migtest_e_ref_name" columnNames="name" oneToOne="false" nullableColumns=""/>
|
||||
</createTable>
|
||||
<createIndex indexName="ix_migtest_e_basic_indextest1" tableName="migtest_e_basic" columns="indextest1"/>
|
||||
<createIndex indexName="ix_migtest_e_basic_indextest5" tableName="migtest_e_basic" columns="indextest5"/>
|
||||
@@ -32,6 +36,9 @@
|
||||
<dropIndex indexName="ix_migtest_e_basic_indextest6" tableName="migtest_e_basic"/>
|
||||
</changeSet>
|
||||
<changeSet type="pendingDrops">
|
||||
<dropColumn columnName="one_key" tableName="migtest_ckey_detail"/>
|
||||
<dropColumn columnName="two_key" tableName="migtest_ckey_detail"/>
|
||||
<dropColumn columnName="assoc_id" tableName="migtest_ckey_parent"/>
|
||||
<dropColumn columnName="new_string_field" tableName="migtest_e_basic"/>
|
||||
<dropColumn columnName="new_boolean_field" tableName="migtest_e_basic"/>
|
||||
<dropColumn columnName="new_boolean_field2" tableName="migtest_e_basic"/>
|
||||
@@ -41,6 +48,9 @@
|
||||
<dropColumn columnName="test_string2" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropColumn columnName="test_string3" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropColumn columnName="deleted" tableName="migtest_e_softdelete"/>
|
||||
<dropColumn columnName="master_id" tableName="migtest_oto_child"/>
|
||||
<dropTable name="migtest_e_user" sequenceCol="id"/>
|
||||
<dropTable name="migtest_mtm_c_migtest_mtm_m"/>
|
||||
<dropTable name="migtest_mtm_m_migtest_mtm_c"/>
|
||||
</changeSet>
|
||||
</migration>
|
||||
@@ -2,6 +2,9 @@
|
||||
<!DOCTYPE xml>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply" dropsFor="1.3">
|
||||
<dropColumn columnName="one_key" tableName="migtest_ckey_detail"/>
|
||||
<dropColumn columnName="two_key" tableName="migtest_ckey_detail"/>
|
||||
<dropColumn columnName="assoc_id" tableName="migtest_ckey_parent"/>
|
||||
<dropColumn columnName="new_string_field" tableName="migtest_e_basic"/>
|
||||
<dropColumn columnName="new_boolean_field" tableName="migtest_e_basic"/>
|
||||
<dropColumn columnName="new_boolean_field2" tableName="migtest_e_basic"/>
|
||||
@@ -11,6 +14,9 @@
|
||||
<dropColumn columnName="test_string2" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropColumn columnName="test_string3" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropColumn columnName="deleted" tableName="migtest_e_softdelete"/>
|
||||
<dropColumn columnName="master_id" tableName="migtest_oto_child"/>
|
||||
<dropTable name="migtest_e_user" sequenceCol="id"/>
|
||||
<dropTable name="migtest_mtm_c_migtest_mtm_m"/>
|
||||
<dropTable name="migtest_mtm_m_migtest_mtm_c"/>
|
||||
</changeSet>
|
||||
</migration>
|
||||
@@ -1,5 +1,25 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer auto_increment not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer auto_increment not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer(127) not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigint auto_increment not null,
|
||||
one_id bigint,
|
||||
@@ -70,6 +90,8 @@ create table migtest_e_history2 (
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer auto_increment not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
@@ -79,6 +101,30 @@ create table migtest_e_softdelete (
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigint auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigint auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
||||
|
||||
@@ -5,6 +5,24 @@ create table migtest_e_user (
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer(127);
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table migtest_fk_cascade drop foreign key fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
||||
@@ -38,6 +56,7 @@ alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest2;
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest6;
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
|
||||
@@ -54,10 +73,29 @@ alter table migtest_e_history2_history add column test_string3 varchar(255);
|
||||
|
||||
alter table migtest_e_softdelete add column deleted tinyint(1) default 0 not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
drop index ix_migtest_e_basic_indextest1 on migtest_e_basic;
|
||||
drop index ix_migtest_e_basic_indextest5 on migtest_e_basic;
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
|
||||
|
||||
alter table migtest_e_history add column sys_period_start datetime(6) default now(6);
|
||||
alter table migtest_e_history add column sys_period_end datetime(6);
|
||||
create table migtest_e_history_history(
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer auto_increment not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail drop foreign key fk_migtest_ckey_detail_parent;
|
||||
alter table migtest_fk_cascade drop foreign key fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
||||
alter table migtest_fk_none drop foreign key fk_migtest_fk_none_one_id;
|
||||
@@ -24,6 +27,7 @@ alter table migtest_e_basic add column old_boolean tinyint(1) default 0 not null
|
||||
alter table migtest_e_basic add column old_boolean2 tinyint(1);
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_status_indextest1;
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
|
||||
|
||||
@@ -9,6 +9,12 @@ drop table migtest_e_history_history;
|
||||
|
||||
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
@@ -27,7 +33,11 @@ alter table migtest_e_history2_history drop column test_string3;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table if exists migtest_e_user;
|
||||
drop table if exists migtest_mtm_c_migtest_mtm_m;
|
||||
drop table if exists migtest_mtm_m_migtest_mtm_c;
|
||||
-- changes: [drop test_string2, drop test_string3]
|
||||
lock tables migtest_e_history2 write;
|
||||
drop trigger migtest_e_history2_history_upd;
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id number(10) not null,
|
||||
assoc_one varchar2(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
create sequence migtest_ckey_assoc_seq;
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id number(10) not null,
|
||||
something varchar2(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
create sequence migtest_ckey_detail_seq;
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key number(127) not null,
|
||||
two_key varchar2(127) not null,
|
||||
name varchar2(255),
|
||||
version number(10) not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id number(19) not null,
|
||||
one_id number(19),
|
||||
@@ -79,6 +101,8 @@ create sequence migtest_e_history2_seq;
|
||||
|
||||
create table migtest_e_ref (
|
||||
id number(10) not null,
|
||||
name varchar2(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
create sequence migtest_e_ref_seq;
|
||||
@@ -90,6 +114,34 @@ create table migtest_e_softdelete (
|
||||
);
|
||||
create sequence migtest_e_softdelete_seq;
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id number(10) not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
create sequence migtest_mtm_c_seq;
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id number(19) not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
create sequence migtest_mtm_m_seq;
|
||||
|
||||
create table migtest_oto_child (
|
||||
id number(10) not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
create sequence migtest_oto_child_seq;
|
||||
|
||||
create table migtest_oto_master (
|
||||
id number(19) not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
create sequence migtest_oto_master_seq;
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
|
||||
@@ -6,6 +6,24 @@ create table migtest_e_user (
|
||||
);
|
||||
create sequence migtest_e_user_seq;
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id number(10) not null,
|
||||
migtest_mtm_m_id number(19) not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id number(19) not null,
|
||||
migtest_mtm_c_id number(10) not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key number(127);
|
||||
alter table migtest_ckey_detail add column two_key varchar2(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key);
|
||||
alter table migtest_ckey_parent add column assoc_id number(10);
|
||||
|
||||
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id);
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id);
|
||||
@@ -40,6 +58,7 @@ alter table migtest_e_basic add column new_integer number(10) default 42 not nul
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_mgtst__bsc_stts_ndxtst1 unique (status,indextest1);
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
|
||||
@@ -55,7 +74,26 @@ alter table migtest_e_history2 add column test_string3 varchar2(255) default 'un
|
||||
|
||||
alter table migtest_e_softdelete add column deleted number(1) default 0 not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id number(19);
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
drop index ix_migtest_e_basic_indextest1;
|
||||
drop index ix_migtest_e_basic_indextest5;
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mtm_c_mgtst_mt_93awga foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
|
||||
create index ix_mgtst_mtm_c_mgtst_mt_3ug4ok on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mtm_c_mgtst_mt_93awgk foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
|
||||
create index ix_mgtst_mtm_c_mgtst_mt_3ug4ou on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mtm_m_mgtst_mt_ggi34k foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
|
||||
create index ix_mgtst_mtm_m_mgtst_mt_b7nbcu on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mtm_m_mgtst_mt_ggi34a foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
|
||||
create index ix_mgtst_mtm_m_mgtst_mt_b7nbck on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_ckey_parent add constraint fk_mgtst_cky_prnt_ssc_d foreign key (assoc_id) references migtest_ckey_assoc (id);
|
||||
create index ix_mgtst_cky_prnt_ssc_d on migtest_ckey_parent (assoc_id);
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id);
|
||||
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id number(10) not null,
|
||||
name varchar2(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
create sequence migtest_e_ref_seq;
|
||||
|
||||
alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent;
|
||||
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id;
|
||||
@@ -28,6 +31,7 @@ alter table migtest_e_basic add column old_boolean number(1) default 0 not null;
|
||||
alter table migtest_e_basic add column old_boolean2 number(1);
|
||||
alter table migtest_e_basic add column eref_id number(10);
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__bsc_stts_ndxtst1;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
@@ -16,5 +22,9 @@ alter table migtest_e_history2 drop column test_string3;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table migtest_e_user cascade constraints purge;
|
||||
drop sequence migtest_e_user_seq;
|
||||
drop table migtest_mtm_c_migtest_mtm_m cascade constraints purge;
|
||||
drop table migtest_mtm_m_migtest_mtm_c cascade constraints purge;
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id serial not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id serial not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigserial not null,
|
||||
one_id bigint,
|
||||
@@ -70,6 +90,8 @@ create table migtest_e_history2 (
|
||||
|
||||
create table migtest_e_ref (
|
||||
id serial not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
@@ -79,6 +101,30 @@ create table migtest_e_softdelete (
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id serial not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigserial not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id serial not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigserial not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
||||
|
||||
@@ -8,6 +8,24 @@ create table migtest_e_user (
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer;
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table if exists migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
||||
@@ -42,6 +60,7 @@ alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
|
||||
@@ -61,10 +80,29 @@ alter table migtest_e_history2_history add column test_string3 varchar(255);
|
||||
|
||||
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
drop index if exists ix_migtest_e_basic_indextest1;
|
||||
drop index if exists ix_migtest_e_basic_indextest5;
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
|
||||
|
||||
alter table migtest_e_history add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
|
||||
create table migtest_e_history_history(like migtest_e_history);
|
||||
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id serial not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
alter table if exists migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent;
|
||||
alter table if exists migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
||||
alter table if exists migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id;
|
||||
@@ -27,6 +30,7 @@ alter table migtest_e_basic add column old_boolean boolean default false not nul
|
||||
alter table migtest_e_basic add column old_boolean2 boolean;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
||||
|
||||
@@ -10,6 +10,12 @@ drop table migtest_e_history_history;
|
||||
drop view if exists migtest_e_history2_with_history;
|
||||
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
@@ -28,8 +34,12 @@ alter table migtest_e_history2_history drop column test_string3;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table if exists migtest_e_user cascade;
|
||||
drop sequence if exists migtest_e_user_seq;
|
||||
drop table if exists migtest_mtm_c_migtest_mtm_m cascade;
|
||||
drop table if exists migtest_mtm_m_migtest_mtm_c cascade;
|
||||
-- changes: [drop test_string2, drop test_string3]
|
||||
create or replace view migtest_e_history2_with_history as select id, test_string, sys_period from migtest_e_history2 union all select id, test_string, sys_period from migtest_e_history2_history;
|
||||
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer(127) not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id integer not null,
|
||||
one_id integer,
|
||||
@@ -73,6 +93,8 @@ create table migtest_e_history2 (
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
@@ -82,5 +104,29 @@ create table migtest_e_softdelete (
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id integer not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id integer not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
|
||||
@@ -5,6 +5,27 @@ create table migtest_e_user (
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id integer not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id),
|
||||
foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict,
|
||||
foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id integer not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id),
|
||||
foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict,
|
||||
foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer(127);
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id;
|
||||
|
||||
@@ -34,6 +55,7 @@ alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
|
||||
@@ -49,7 +71,12 @@ alter table migtest_e_history2_history add column test_string3 varchar(255);
|
||||
|
||||
alter table migtest_e_softdelete add column deleted int default 0 not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id integer;
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
drop index if exists ix_migtest_e_basic_indextest1;
|
||||
drop index if exists ix_migtest_e_basic_indextest5;
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent;
|
||||
alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id;
|
||||
alter table migtest_fk_none_via_join drop constraint if exists fk_migtest_fk_none_via_join_one_id;
|
||||
@@ -25,6 +28,7 @@ alter table migtest_e_basic add column old_boolean int default 0 not null;
|
||||
alter table migtest_e_basic add column old_boolean2 int;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
@@ -18,4 +24,8 @@ alter table migtest_e_history2_history drop column test_string3;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table if exists migtest_e_user;
|
||||
drop table if exists migtest_mtm_c_migtest_mtm_m;
|
||||
drop table if exists migtest_mtm_m_migtest_mtm_c;
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
create sequence migtest_ckey_assoc_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
create sequence migtest_ckey_detail_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id numeric(19) not null,
|
||||
one_id numeric(19),
|
||||
@@ -79,8 +101,10 @@ create sequence migtest_e_history2_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
|
||||
create sequence migtest_e_ref_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
@@ -90,6 +114,34 @@ create table migtest_e_softdelete (
|
||||
);
|
||||
create sequence migtest_e_softdelete_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
create sequence migtest_mtm_c_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id numeric(19) not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
create sequence migtest_mtm_m_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
create sequence migtest_oto_child_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_oto_master (
|
||||
id numeric(19) not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
create sequence migtest_oto_master_seq as bigint start with 1 ;
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
||||
|
||||
@@ -6,6 +6,24 @@ create table migtest_e_user (
|
||||
);
|
||||
create sequence migtest_e_user_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id numeric(19) not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id numeric(19) not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add one_key integer;
|
||||
alter table migtest_ckey_detail add two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key);
|
||||
alter table migtest_ckey_parent add assoc_id integer;
|
||||
|
||||
IF OBJECT_ID('fk_migtest_fk_cascade_one_id', 'F') IS NOT NULL alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id);
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id);
|
||||
@@ -42,6 +60,7 @@ IF (OBJECT_ID('uq_migtest_e_basic_indextest2', 'UQ') IS NOT NULL) alter table mi
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_indextest2') drop index uq_migtest_e_basic_indextest2 ON migtest_e_basic;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_indextest6', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_indextest6') drop index uq_migtest_e_basic_indextest6 ON migtest_e_basic;
|
||||
create unique nonclustered index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) where indextest1 is not null;
|
||||
create unique nonclustered index uq_migtest_e_basic_name on migtest_e_basic(name) where name is not null;
|
||||
create unique nonclustered index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) where indextest4 is not null;
|
||||
create unique nonclustered index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) where indextest5 is not null;
|
||||
@@ -55,10 +74,29 @@ alter table migtest_e_history2 add test_string3 varchar(255) default 'unknown' n
|
||||
|
||||
alter table migtest_e_softdelete add deleted bit default 0 not null;
|
||||
|
||||
alter table migtest_oto_child add master_id numeric(19);
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest1') drop index ix_migtest_e_basic_indextest1 ON migtest_e_basic;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest5') drop index ix_migtest_e_basic_indextest5 ON migtest_e_basic;
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
|
||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id);
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id);
|
||||
|
||||
alter table migtest_e_history
|
||||
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
|
||||
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
|
||||
create sequence migtest_e_ref_seq as bigint start with 1 ;
|
||||
|
||||
IF OBJECT_ID('fk_migtest_ckey_detail_parent', 'F') IS NOT NULL alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent;
|
||||
IF OBJECT_ID('fk_migtest_fk_cascade_one_id', 'F') IS NOT NULL alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
||||
IF OBJECT_ID('fk_migtest_fk_none_one_id', 'F') IS NOT NULL alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id;
|
||||
@@ -35,6 +38,8 @@ alter table migtest_e_basic add old_boolean bit default 0 not null;
|
||||
alter table migtest_e_basic add old_boolean2 bit;
|
||||
alter table migtest_e_basic add eref_id integer;
|
||||
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_status_indextest1', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_status_indextest1') drop index uq_migtest_e_basic_status_indextest1 ON migtest_e_basic;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_name', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_name') drop index uq_migtest_e_basic_name ON migtest_e_basic;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_indextest4', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
|
||||
@@ -1,5 +1,44 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
-- drop column migtest_ckey_detail.one_key;
|
||||
IF (OBJECT_ID('uq_migtest_ckey_detail_one_key', 'UQ') IS NOT NULL) alter table migtest_ckey_detail drop constraint uq_migtest_ckey_detail_one_key;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_detail','U') AND name = 'uq_migtest_ckey_detail_one_key') drop index uq_migtest_ckey_detail_one_key ON migtest_ckey_detail;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);select @Tmp = t1.name from sys.default_constraints t1
|
||||
join sys.columns t2 on t1.object_id = t2.default_object_id
|
||||
where t1.parent_object_id = OBJECT_ID('migtest_ckey_detail') and t2.name = 'one_key';
|
||||
if @Tmp is not null EXEC('alter table migtest_ckey_detail drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_ckey_detail_one_key', 'C') IS NOT NULL) alter table migtest_ckey_detail drop constraint ck_migtest_ckey_detail_one_key;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_detail','U') AND name = 'ix_migtest_ckey_detail_one_key') drop index ix_migtest_ckey_detail_one_key ON migtest_ckey_detail;
|
||||
IF OBJECT_ID('fk_migtest_ckey_detail_one_key', 'F') IS NOT NULL alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_one_key;
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
-- drop column migtest_ckey_detail.two_key;
|
||||
IF (OBJECT_ID('uq_migtest_ckey_detail_two_key', 'UQ') IS NOT NULL) alter table migtest_ckey_detail drop constraint uq_migtest_ckey_detail_two_key;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_detail','U') AND name = 'uq_migtest_ckey_detail_two_key') drop index uq_migtest_ckey_detail_two_key ON migtest_ckey_detail;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);select @Tmp = t1.name from sys.default_constraints t1
|
||||
join sys.columns t2 on t1.object_id = t2.default_object_id
|
||||
where t1.parent_object_id = OBJECT_ID('migtest_ckey_detail') and t2.name = 'two_key';
|
||||
if @Tmp is not null EXEC('alter table migtest_ckey_detail drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_ckey_detail_two_key', 'C') IS NOT NULL) alter table migtest_ckey_detail drop constraint ck_migtest_ckey_detail_two_key;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_detail','U') AND name = 'ix_migtest_ckey_detail_two_key') drop index ix_migtest_ckey_detail_two_key ON migtest_ckey_detail;
|
||||
IF OBJECT_ID('fk_migtest_ckey_detail_two_key', 'F') IS NOT NULL alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_two_key;
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
-- drop column migtest_ckey_parent.assoc_id;
|
||||
IF (OBJECT_ID('uq_migtest_ckey_parent_assoc_id', 'UQ') IS NOT NULL) alter table migtest_ckey_parent drop constraint uq_migtest_ckey_parent_assoc_id;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_parent','U') AND name = 'uq_migtest_ckey_parent_assoc_id') drop index uq_migtest_ckey_parent_assoc_id ON migtest_ckey_parent;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);select @Tmp = t1.name from sys.default_constraints t1
|
||||
join sys.columns t2 on t1.object_id = t2.default_object_id
|
||||
where t1.parent_object_id = OBJECT_ID('migtest_ckey_parent') and t2.name = 'assoc_id';
|
||||
if @Tmp is not null EXEC('alter table migtest_ckey_parent drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_ckey_parent_assoc_id', 'C') IS NOT NULL) alter table migtest_ckey_parent drop constraint ck_migtest_ckey_parent_assoc_id;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_parent','U') AND name = 'ix_migtest_ckey_parent_assoc_id') drop index ix_migtest_ckey_parent_assoc_id ON migtest_ckey_parent;
|
||||
IF OBJECT_ID('fk_migtest_ckey_parent_assoc_id', 'F') IS NOT NULL alter table migtest_ckey_parent drop constraint fk_migtest_ckey_parent_assoc_id;
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
-- drop column migtest_e_basic.new_string_field;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_new_string_field', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_new_string_field;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_new_string_field') drop index uq_migtest_e_basic_new_string_field ON migtest_e_basic;
|
||||
@@ -104,8 +143,23 @@ IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_s
|
||||
IF OBJECT_ID('fk_migtest_e_softdelete_deleted', 'F') IS NOT NULL alter table migtest_e_softdelete drop constraint fk_migtest_e_softdelete_deleted;
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
-- drop column migtest_oto_child.master_id;
|
||||
IF (OBJECT_ID('uq_migtest_oto_child_master_id', 'UQ') IS NOT NULL) alter table migtest_oto_child drop constraint uq_migtest_oto_child_master_id;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_oto_child','U') AND name = 'uq_migtest_oto_child_master_id') drop index uq_migtest_oto_child_master_id ON migtest_oto_child;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);select @Tmp = t1.name from sys.default_constraints t1
|
||||
join sys.columns t2 on t1.object_id = t2.default_object_id
|
||||
where t1.parent_object_id = OBJECT_ID('migtest_oto_child') and t2.name = 'master_id';
|
||||
if @Tmp is not null EXEC('alter table migtest_oto_child drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_oto_child_master_id', 'C') IS NOT NULL) alter table migtest_oto_child drop constraint ck_migtest_oto_child_master_id;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_oto_child','U') AND name = 'ix_migtest_oto_child_master_id') drop index ix_migtest_oto_child_master_id ON migtest_oto_child;
|
||||
IF OBJECT_ID('fk_migtest_oto_child_master_id', 'F') IS NOT NULL alter table migtest_oto_child drop constraint fk_migtest_oto_child_master_id;
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
IF OBJECT_ID('migtest_e_user', 'U') IS NOT NULL drop table migtest_e_user;
|
||||
IF OBJECT_ID('migtest_e_user_seq', 'SO') IS NOT NULL drop sequence migtest_e_user_seq;
|
||||
IF OBJECT_ID('migtest_mtm_c_migtest_mtm_m', 'U') IS NOT NULL drop table migtest_mtm_c_migtest_mtm_m;
|
||||
IF OBJECT_ID('migtest_mtm_m_migtest_mtm_c', 'U') IS NOT NULL drop table migtest_mtm_m_migtest_mtm_c;
|
||||
-- dropping history support for migtest_e_history;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);select @Tmp = t1.name from sys.default_constraints t1
|
||||
|
||||
Reference in New Issue
Block a user