diff --git a/h2-migration.xml b/h2-migration.xml index 0d29627a3..0275b2508 100644 --- a/h2-migration.xml +++ b/h2-migration.xml @@ -1,24 +1,24 @@ - + - + - + - + @@ -27,12 +27,12 @@ - + - + @@ -41,12 +41,12 @@ - + - + @@ -54,7 +54,7 @@ - + @@ -62,99 +62,101 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + - + @@ -162,7 +164,7 @@ - + @@ -170,10 +172,10 @@ - + - + @@ -185,14 +187,14 @@ - + - + @@ -201,7 +203,7 @@ - + @@ -210,11 +212,11 @@ - + - + @@ -226,14 +228,14 @@ - + - + @@ -243,121 +245,121 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -365,20 +367,20 @@ - + - + - + @@ -395,7 +397,7 @@ - + @@ -408,21 +410,21 @@ - + - + - + - + @@ -430,7 +432,7 @@ - + @@ -438,14 +440,14 @@ - + - + @@ -458,25 +460,25 @@ - + - + - + - + - + @@ -485,33 +487,33 @@ - + - + - + - + - + - + @@ -520,15 +522,15 @@ - + - + - + @@ -536,12 +538,12 @@ - + - + @@ -553,35 +555,35 @@ - + - + - + - + - + - - + + @@ -595,35 +597,41 @@ - + + + + + - + + + - + - + - + @@ -633,20 +641,22 @@ + + - + - + - + @@ -657,49 +667,51 @@ - + - + - + - + + + - + - + - + - + - + @@ -709,12 +721,12 @@ - + - + @@ -722,24 +734,26 @@ + + - + - + - + - + @@ -750,19 +764,21 @@ - + + + - + - + @@ -783,7 +799,7 @@ - + @@ -792,7 +808,7 @@ - + @@ -802,17 +818,17 @@ - + - + - + @@ -820,16 +836,16 @@ - + - + - + @@ -838,7 +854,7 @@ - + @@ -849,22 +865,22 @@ - + - + - + - + @@ -872,8 +888,10 @@ + + - + @@ -887,14 +905,14 @@ - + - + @@ -902,22 +920,22 @@ - + - + - + - + @@ -932,26 +950,28 @@ + + - + - - + + - + - + @@ -965,17 +985,19 @@ + + - + - + - + @@ -984,34 +1006,34 @@ - + - + - + - + - + - + @@ -1026,7 +1048,7 @@ - + @@ -1034,12 +1056,12 @@ - + - + @@ -1047,63 +1069,63 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -1113,11 +1135,11 @@ - + - + @@ -1127,16 +1149,16 @@ - + - + - + @@ -1146,18 +1168,18 @@ - + - + - + - + @@ -1165,7 +1187,7 @@ - + @@ -1180,15 +1202,15 @@ - + - + - + @@ -1198,7 +1220,7 @@ - + @@ -1206,11 +1228,11 @@ - - - + + + - + @@ -1223,7 +1245,7 @@ - + @@ -1233,42 +1255,44 @@ - + + + - + - + - + - + - + - + diff --git a/h2autocommit-migration.xml b/h2autocommit-migration.xml new file mode 100644 index 000000000..e009d4272 --- /dev/null +++ b/h2autocommit-migration.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/h2other-migration.xml b/h2other-migration.xml new file mode 100644 index 000000000..b58887866 --- /dev/null +++ b/h2other-migration.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java index c993f6506..45babee6a 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java @@ -13,7 +13,8 @@ public class H2Platform extends DatabasePlatform { public H2Platform() { super(); this.name = "h2"; - this.platformDdl = new H2Ddl(this.dbTypeMap); + boolean useSequences = true; + this.platformDdl = new H2Ddl(this.dbTypeMap, useSequences); this.dbEncrypt = new H2DbEncrypt(); // like ? escape'' not working in the latest version H2 so just using no // escape clause for now noting that backslash is an escape char for like in H2 diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java index fdbe744ee..1e104fca3 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java @@ -6,10 +6,10 @@ import com.avaje.ebean.dbmigration.ddlgeneration.TableDdl; import com.avaje.ebean.dbmigration.migration.Column; import com.avaje.ebean.dbmigration.migration.CreateTable; import com.avaje.ebean.dbmigration.migration.ForeignKey; -import com.avaje.ebean.dbmigration.migration.PrimaryKey; import com.avaje.ebean.dbmigration.model.MTable; import java.io.IOException; +import java.math.BigInteger; import java.util.ArrayList; import java.util.List; @@ -54,29 +54,40 @@ public class BaseTableDdl implements TableDdl { if (!pk.isEmpty()) { // defined on the columns writePrimaryKeyConstraint(apply, tableName, toColumnNames(pk)); - } else { - // defined on the table - if (createTable.getPrimaryKey() == null) { - System.out.print("asd"); - } else { - writePrimaryKeyConstraint(apply, tableName, createTable.getPrimaryKey()); - } } apply.newLine().append(")").endOfStatement(); + + // add drop table to the rollback buffer - do this before + // we drop the related sequence (if sequences are used) + dropTable(writer.rollback(), tableName); + + writeSequence(writer, createTable); + + // add blank line for a bit of whitespace between tables apply.end(); + writer.rollback().end(); writeAddForeignKeys(writer, createTable); - // add drop table to the rollback buffer - dropTable(writer.rollback(), tableName); - if (isTrue(createTable.isWithHistory())) { createWithHistory(writer, createTable.getName()); } } + private void writeSequence(DdlWrite writer, CreateTable createTable) throws IOException { + String name = createTable.getSequenceName(); + int initial = toInt(createTable.getSequenceInitial()); + int allocate = toInt(createTable.getSequenceAllocate()); + + String createSeq = platformDdl.createSequence(name, initial, allocate); + if (createSeq != null) { + writer.apply().append(createSeq).newLine(); + writer.rollback().append(platformDdl.dropSequence(name)); + } + } + private void createWithHistory(DdlWrite writer, String name) throws IOException { MTable table = writer.getTable(name); @@ -183,7 +194,7 @@ public class BaseTableDdl implements TableDdl { */ protected void dropTable(DdlBuffer buffer, String tableName) throws IOException { - buffer.append("drop table ").append(tableName).endOfStatement().end(); + buffer.append("drop table ").append(tableName).endOfStatement(); } /** @@ -243,13 +254,6 @@ public class BaseTableDdl implements TableDdl { buffer.append(")"); } - protected void writePrimaryKeyConstraint(DdlBuffer buffer, String tableName, PrimaryKey pk) throws IOException { - - String columnNames = pk.getColumnNames(); - String[] cols = columnNames.split(","); - writePrimaryKeyConstraint(buffer, tableName, cols); - } - /** * Write the primary key constraint inline with the create table statement. */ @@ -390,5 +394,8 @@ public class BaseTableDdl implements TableDdl { return Boolean.TRUE.equals(value); } + private int toInt(BigInteger value) { + return (value == null) ? 0 : value.intValue(); + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2Ddl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2Ddl.java index fe4dd8104..c10166421 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2Ddl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2Ddl.java @@ -7,8 +7,10 @@ import com.avaje.ebean.config.dbplatform.DbTypeMap; */ public class H2Ddl extends PlatformDdl { - public H2Ddl(DbTypeMap platformTypes) { + public H2Ddl(DbTypeMap platformTypes, boolean useSequences) { super(platformTypes, new H2HistoryDdl()); this.foreignKeyRestrict = "on delete restrict on update restrict"; + this.useSequences = useSequences; } + } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java index 0a629a2b7..b2691d8fa 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java @@ -17,6 +17,8 @@ public class PlatformDdl { protected String foreignKeyRestrict = ""; + protected boolean useSequences; + public PlatformDdl(DbTypeMap platformTypes, PlatformHistoryDdl historyDdl) { this.typeConverter = new PlatformTypeConverter(platformTypes); this.historyDdl = historyDdl; @@ -50,4 +52,31 @@ public class PlatformDdl { public void createWithHistory(DdlWrite writer, MTable table) throws IOException { historyDdl.createWithHistory(writer, table); } + + /** + * Generate and return the create sequence DDL. + */ + public String createSequence(String sequenceName, int initialValue, int allocationSize) { + + if (!useSequences || sequenceName == null || sequenceName.trim().length() == 0) { + return null; + } + + StringBuilder sb = new StringBuilder("create sequence "); + sb.append(sequenceName); + if (initialValue > 1) { + sb.append(" start with ").append(initialValue); + } + if (allocationSize > 0 && allocationSize != 50) { + // at this stage ignoring allocationSize 50 as this is the 'default' and + // not consistent with the way Ebean batch fetches sequence values + sb.append(" increment by ").append(allocationSize); + } + sb.append(";"); + return sb.toString(); + } + + public String dropSequence(String sequenceName) { + return "drop sequence "+sequenceName+";"; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresDdl.java index 350af181e..1ff011a7b 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresDdl.java @@ -8,8 +8,13 @@ import com.avaje.ebean.config.dbplatform.DbTypeMap; public class PostgresDdl extends PlatformDdl { public PostgresDdl(DbTypeMap platformTypes) { + this(platformTypes, false); + } + + public PostgresDdl(DbTypeMap platformTypes, boolean useSequences) { super(platformTypes, new PostgresHistoryDdl()); this.foreignKeyRestrict = "on delete restrict on update restrict"; + this.useSequences = useSequences; } /** diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java index 5d14d95bd..c48197d94 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java @@ -1,6 +1,7 @@ package com.avaje.ebean.dbmigration.migration; +import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; @@ -8,6 +9,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; @@ -24,11 +26,13 @@ import javax.xml.bind.annotation.XmlType; * <element ref="{http://ebean-orm.github.io/xml/ns/dbmigration}column" maxOccurs="unbounded"/> * <element ref="{http://ebean-orm.github.io/xml/ns/dbmigration}uniqueConstraint" maxOccurs="unbounded" minOccurs="0"/> * <element ref="{http://ebean-orm.github.io/xml/ns/dbmigration}foreignKey" maxOccurs="unbounded" minOccurs="0"/> - * <element ref="{http://ebean-orm.github.io/xml/ns/dbmigration}primaryKey" minOccurs="0"/> * </sequence> * <attGroup ref="{http://ebean-orm.github.io/xml/ns/dbmigration}tablespaceAttributes"/> * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" /> * <attribute name="withHistory" type="{http://www.w3.org/2001/XMLSchema}boolean" /> + * <attribute name="sequenceName" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="sequenceInitial" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" /> + * <attribute name="sequenceAllocate" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" /> * </restriction> * </complexContent> * </complexType> @@ -40,8 +44,7 @@ import javax.xml.bind.annotation.XmlType; @XmlType(name = "", propOrder = { "column", "uniqueConstraint", - "foreignKey", - "primaryKey" + "foreignKey" }) @XmlRootElement(name = "createTable") public class CreateTable { @@ -50,11 +53,18 @@ public class CreateTable { protected List column; protected List uniqueConstraint; protected List foreignKey; - protected PrimaryKey primaryKey; @XmlAttribute(name = "name", required = true) protected String name; @XmlAttribute(name = "withHistory") protected Boolean withHistory; + @XmlAttribute(name = "sequenceName") + protected String sequenceName; + @XmlAttribute(name = "sequenceInitial") + @XmlSchemaType(name = "positiveInteger") + protected BigInteger sequenceInitial; + @XmlAttribute(name = "sequenceAllocate") + @XmlSchemaType(name = "positiveInteger") + protected BigInteger sequenceAllocate; @XmlAttribute(name = "tablespace") protected String tablespace; @XmlAttribute(name = "indexTablespace") @@ -149,30 +159,6 @@ public class CreateTable { return this.foreignKey; } - /** - * Gets the value of the primaryKey property. - * - * @return - * possible object is - * {@link PrimaryKey } - * - */ - public PrimaryKey getPrimaryKey() { - return primaryKey; - } - - /** - * Sets the value of the primaryKey property. - * - * @param value - * allowed object is - * {@link PrimaryKey } - * - */ - public void setPrimaryKey(PrimaryKey value) { - this.primaryKey = value; - } - /** * Gets the value of the name property. * @@ -221,6 +207,78 @@ public class CreateTable { this.withHistory = value; } + /** + * Gets the value of the sequenceName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSequenceName() { + return sequenceName; + } + + /** + * Sets the value of the sequenceName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSequenceName(String value) { + this.sequenceName = value; + } + + /** + * Gets the value of the sequenceInitial property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getSequenceInitial() { + return sequenceInitial; + } + + /** + * Sets the value of the sequenceInitial property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setSequenceInitial(BigInteger value) { + this.sequenceInitial = value; + } + + /** + * Gets the value of the sequenceAllocate property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getSequenceAllocate() { + return sequenceAllocate; + } + + /** + * Sets the value of the sequenceAllocate property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setSequenceAllocate(BigInteger value) { + this.sequenceAllocate = value; + } + /** * Gets the value of the tablespace property. * diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java new file mode 100644 index 000000000..aebea69ce --- /dev/null +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java @@ -0,0 +1,114 @@ + +package com.avaje.ebean.dbmigration.migration; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="columnNames" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="refColumnNames" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="refTableName" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "foreignKey") +public class ForeignKey { + + @XmlAttribute(name = "columnNames", required = true) + protected String columnNames; + @XmlAttribute(name = "refColumnNames", required = true) + protected String refColumnNames; + @XmlAttribute(name = "refTableName", required = true) + protected String refTableName; + + /** + * Gets the value of the columnNames property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getColumnNames() { + return columnNames; + } + + /** + * Sets the value of the columnNames property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setColumnNames(String value) { + this.columnNames = value; + } + + /** + * Gets the value of the refColumnNames property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRefColumnNames() { + return refColumnNames; + } + + /** + * Sets the value of the refColumnNames property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRefColumnNames(String value) { + this.refColumnNames = value; + } + + /** + * Gets the value of the refTableName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRefTableName() { + return refTableName; + } + + /** + * Sets the value of the refTableName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRefTableName(String value) { + this.refTableName = value; + } + +} diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java index be3d2564c..1b9610b16 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java @@ -61,14 +61,6 @@ public class ObjectFactory { return new ForeignKey(); } - /** - * Create an instance of {@link PrimaryKey } - * - */ - public PrimaryKey createPrimaryKey() { - return new PrimaryKey(); - } - /** * Create an instance of {@link DropForeignKey } * diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MTable.java b/src/main/java/com/avaje/ebean/dbmigration/model/MTable.java index 71510e356..616168e53 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MTable.java @@ -6,6 +6,7 @@ import com.avaje.ebean.dbmigration.migration.CreateTable; import com.avaje.ebean.dbmigration.migration.DropColumn; import com.avaje.ebean.dbmigration.migration.ForeignKey; +import java.math.BigInteger; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -40,6 +41,9 @@ public class MTable { private String tablespace; private String indexTablespace; + private String sequenceName; + private int sequenceInitial; + private int sequenceAllocate; private Boolean withHistory; @@ -57,12 +61,16 @@ public class MTable { this.tablespace = createTable.getTablespace(); this.indexTablespace = createTable.getIndexTablespace(); this.withHistory = createTable.isWithHistory(); + this.sequenceName = createTable.getSequenceName(); + this.sequenceInitial = toInt(createTable.getSequenceInitial()); + this.sequenceAllocate = toInt(createTable.getSequenceAllocate()); List cols = createTable.getColumn(); for (Column column : cols) { addColumn(column); } } + /** * Construct typically from EbeanServer meta data. */ @@ -78,6 +86,9 @@ public class MTable { createTable.setTablespace(tablespace); createTable.setIndexTablespace(indexTablespace); createTable.setWithHistory(withHistory); + createTable.setSequenceName(sequenceName); + createTable.setSequenceInitial(toBigInteger(sequenceInitial)); + createTable.setSequenceAllocate(toBigInteger(sequenceAllocate)); for (MColumn column : this.columns.values()) { createTable.getColumn().add(column.createColumn()); @@ -148,6 +159,30 @@ public class MTable { return compoundKeys; } + public String getSequenceName() { + return sequenceName; + } + + public void setSequenceName(String sequenceName) { + this.sequenceName = sequenceName; + } + + public int getSequenceInitial() { + return sequenceInitial; + } + + public void setSequenceInitial(int sequenceInitial) { + this.sequenceInitial = sequenceInitial; + } + + public int getSequenceAllocate() { + return sequenceAllocate; + } + + public void setSequenceAllocate(int sequenceAllocate) { + this.sequenceAllocate = sequenceAllocate; + } + /** * Return the list of columns that make the primary key. */ @@ -203,4 +238,30 @@ public class MTable { compoundKeys.add(compoundKey); } + private int toInt(BigInteger value) { + return (value == null) ? 0 : value.intValue(); + } + + private BigInteger toBigInteger(int value) { + return (value == 0) ? null : BigInteger.valueOf(value); + } + + /** + * Add a column checking if it already exists and if so return the existing column. + * Sometimes the case for a primaryKey that is also a foreign key. + */ + public MColumn addColumn(String dbCol, String columnDefn, boolean notnull) { + + MColumn existingColumn = columns.get(dbCol); + if (existingColumn != null) { + if (notnull) { + existingColumn.setNotnull(true); + } + return existingColumn; + } + + MColumn newCol = new MColumn(dbCol, columnDefn, notnull); + addColumn(newCol); + return newCol; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java b/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java index 7eed356cf..5e7af8e30 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java @@ -105,6 +105,11 @@ public class ModelContainer { * Add a table (typically from reading EbeanServer meta data). */ public void addTable(MTable table) { + + if (table.getName().equalsIgnoreCase("item")) { + System.out.println(); + } + tables.put(table.getName(), table); } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitor.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitor.java index a0af0d6d1..025f3cf14 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitor.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitor.java @@ -35,6 +35,10 @@ public class ModelBuildBeanVisitor implements BeanVisitor { MTable table = new MTable(descriptor.getBaseTable()); + table.setSequenceName(descriptor.getSequenceName()); + table.setSequenceInitial(descriptor.getSequenceInitialValue()); + table.setSequenceAllocate(descriptor.getSequenceAllocationSize()); + // add the table to the model ctx.addTable(table); diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java index fbf6dfd23..1ac843a24 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java @@ -5,6 +5,7 @@ import com.avaje.ebean.config.dbplatform.DbTypeMap; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebean.dbmigration.model.MTable; import com.avaje.ebean.dbmigration.model.ModelContainer; +import com.avaje.ebeaninternal.server.type.ScalarType; /** * The context used during DDL generation. @@ -49,14 +50,23 @@ public class ModelBuildContext { if (p.isDbEncrypted()) { return dbTypeMap.get(p.getDbEncryptedType()); } + if (p.isLocalEncrypted()) { + // scalar type potentially wrapping varbinary db type + ScalarType scalarType = p.getScalarType(); + int jdbcType = scalarType.getJdbcType(); + return dbTypeMap.get(jdbcType); + } +// ScalarType scalarType = p.getScalarType(); +// if (scalarType == null) { +// throw new RuntimeException("No scalarType for " + p.getFullBeanName()); +// } +// return dbTypeMap.get(scalarType.getJdbcType()); + + // can be the logical JSON types (JSON, JSONB, JSONClob, JSONBlob, JSONVarchar) int dbType = p.getDbType(); if (dbType == 0) { -// ScalarType scalarType = p.getScalarType(); -// if (scalarType == null) { - throw new RuntimeException("No scalarType for " + p.getFullBeanName()); -// } -// dbType = scalarType.getJdbcType(); + throw new RuntimeException("No scalarType defined for " + p.getFullBeanName()); } return dbTypeMap.get(dbType); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java index 49f153277..055d68c2d 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java @@ -1,5 +1,7 @@ package com.avaje.ebean.dbmigration.model.build; +import com.avaje.ebean.dbmigration.migration.ForeignKey; +import com.avaje.ebean.dbmigration.model.MCompoundForeignKey; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; @@ -20,6 +22,8 @@ public class ModelBuildIntersectionTable { private final TableJoin intersectionTableJoin; private final TableJoin tableJoin; + private MTable intersectionTable; + public ModelBuildIntersectionTable(ModelBuildContext ctx, BeanPropertyAssocMany manyProp) { this.ctx = ctx; this.manyProp = manyProp; @@ -29,44 +33,49 @@ public class ModelBuildIntersectionTable { public void build() { - MTable table = createTable(); - ctx.addTable(table); + intersectionTable = createTable(); + ctx.addTable(intersectionTable); - //buildFkConstraints(); + buildFkConstraints(); } -// private void buildFkConstraints(MTable table) { -// -// BeanDescriptor localDesc = manyProp.getBeanDescriptor(); -// String fk1 = buildFkConstraints(localDesc, intersectionTableJoin.columns(), true); -// ctx.addIntersectionTableFk(fk1); -// -// BeanDescriptor targetDesc = manyProp.getTargetDescriptor(); -// String fk2 = buildFkConstraints(targetDesc, tableJoin.columns(), false); -// ctx.addIntersectionTableFk(fk2); -// } + private void buildFkConstraints() { + + BeanDescriptor localDesc = manyProp.getBeanDescriptor(); + buildFkConstraints(localDesc, intersectionTableJoin.columns(), true); + //ctx.addIntersectionTableFk(fk1); + + BeanDescriptor targetDesc = manyProp.getTargetDescriptor(); + buildFkConstraints(targetDesc, tableJoin.columns(), false); + //ctx.addIntersectionTableFk(fk2); + } -// private String buildFkConstraints(BeanDescriptor desc, TableJoinColumn[] columns, boolean direction) { -// -// + private void buildFkConstraints(BeanDescriptor desc, TableJoinColumn[] columns, boolean direction) { + + // String fkName = "fk_"+intersectionTableJoin.getTable()+"_"+desc.getBaseTable(); // // fkName = getFkNameWithSuffix(fkName); -// + + MCompoundForeignKey foreignKey = new MCompoundForeignKey(desc.getBaseTable()); + intersectionTable.addForeignKey(foreignKey); + + // fkBuf.append("alter table "); // fkBuf.append(intersectionTableJoin.getTable()); // fkBuf.append(" add constraint ").append(fkName); // // fkBuf.append(" foreign key ("); -// -// for (int i = 0; i < columns.length; i++) { + + for (int i = 0; i < columns.length; i++) { // if (i > 0) { // fkBuf.append(", "); // } -// String col = direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn(); -// fkBuf.append(col); -// } + String localCol = direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn(); + String refCol = !direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn(); + foreignKey.addColumnPair(localCol, refCol); + } // fkBuf.append(") references ").append(desc.getBaseTable()).append(" ("); // // for (int i = 0; i < columns.length; i++) { @@ -86,7 +95,7 @@ public class ModelBuildIntersectionTable { // fkBuf.append(";").append(NEW_LINE); // // return fkBuf.toString(); -// } + } private MTable createTable() { diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java index d13d72858..668b056be 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java @@ -99,16 +99,20 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { String columnDefn = ctx.getColumnDefn(importedProperty); String refColumn = importedProperty.getDbColumn(); - MColumn col = new MColumn(dbCol, columnDefn, !p.isNullable()); + MColumn col = table.addColumn(dbCol, columnDefn, !p.isNullable()); + if (columns.length == 1) { // single references column (put it on the column) String refTable = importedProperty.getBeanDescriptor().getBaseTable(); + if (refTable == null) { + // odd case where an EmbeddedId only has 1 property + refTable = p.getTargetDescriptor().getBaseTable(); + } col.setReferences(refTable + "." + refColumn); } else { compoundKey.addColumnPair(dbCol, refColumn); } modelColumns.add(col); - table.addColumn(col); } @@ -127,6 +131,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { public void visitScalar(BeanProperty p) { if (p.isSecondaryTable()) { + lastColumn = null; return; } diff --git a/src/main/resources/ebean-dbmigration-1.0.xsd b/src/main/resources/ebean-dbmigration-1.0.xsd index f69a6b13b..2317c08a9 100644 --- a/src/main/resources/ebean-dbmigration-1.0.xsd +++ b/src/main/resources/ebean-dbmigration-1.0.xsd @@ -107,10 +107,12 @@ - + + + @@ -132,13 +134,6 @@ - - - - - - - diff --git a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/BaseDdlHandlerTest.java b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/BaseDdlHandlerTest.java index 2dc801c77..6b7d6fe9a 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/BaseDdlHandlerTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/BaseDdlHandlerTest.java @@ -21,7 +21,7 @@ public class BaseDdlHandlerTest extends BaseTestCase { private BaseDdlHandler h2Handler() { DbTypeMap types = new H2Platform().getDbTypeMap(); - return new BaseDdlHandler(new DdlNamingConvention(), new H2Ddl(types)); + return new BaseDdlHandler(new DdlNamingConvention(), new H2Ddl(types, true)); } private BaseDdlHandler postgresHandler() { diff --git a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java index f0220f62b..21b4c78ef 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java @@ -18,7 +18,7 @@ public class BaseTableDdlTest { @Test public void testGenerate() throws Exception { - BaseTableDdl ddlGen = new BaseTableDdl(new DdlNamingConvention(), new H2Ddl(new DbTypeMap())); + BaseTableDdl ddlGen = new BaseTableDdl(new DdlNamingConvention(), new H2Ddl(new DbTypeMap(), true)); DdlWrite write = new DdlWrite(); diff --git a/src/test/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriterTest.java b/src/test/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriterTest.java index 9ce0538d5..89c1a5b38 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriterTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriterTest.java @@ -14,7 +14,7 @@ public class MigrationXmlWriterTest { @Test public void testWrite() throws Exception { - Migration migration = MigrationXmlReader.read("/test/container/test-create-table.xml"); + Migration migration = MigrationXmlReader.read("/container/test-create-table.xml"); File temp = File.createTempFile("migrationWrite",".xml"); MigrationXmlWriter writer = new MigrationXmlWriter(); diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/ModelContainerApplyTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/ModelContainerApplyTest.java index c15a7db50..57fe09f4d 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/ModelContainerApplyTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/ModelContainerApplyTest.java @@ -17,7 +17,7 @@ public class ModelContainerApplyTest { @Test public void testApply() throws Exception { - Migration migration = MigrationXmlReader.read("/test/container/test-create-table.xml"); + Migration migration = MigrationXmlReader.read("/container/test-create-table.xml"); List changeSets = migration.getChangeSet(); ChangeSet changeSet = changeSets.get(0); diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitorTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitorTest.java index 96a5305de..8bf193fb1 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitorTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitorTest.java @@ -25,9 +25,14 @@ public class ModelBuildBeanVisitorTest extends BaseTestCase { new VisitAllUsing(addTable, defaultServer).visitAllBeans(); + MTable item = model.getTable("item"); + + assertThat(item).isNotNull(); + assertThat(item.primaryKeyColumns()).hasSize(2); + MTable customer = model.getTable("o_customer"); assertThat(customer).isNotNull(); - + assertThat(customer.getSequenceName()).isNotNull(); } } \ No newline at end of file diff --git a/src/test/resources/assert/changeset-apply.txt b/src/test/resources/assert/changeset-apply.txt index a5439ec18..1830ca403 100644 --- a/src/test/resources/assert/changeset-apply.txt +++ b/src/test/resources/assert/changeset-apply.txt @@ -1,182 +1,1908 @@ -create table o_address ( +create table asimple_bean ( id bigint not null, - line1 varchar(100), - line2 varchar(100), - city varchar(100), - country_code varchar(2), + name varchar(255), + constraint pk_asimple_bean primary key (id) +); +create sequence asimple_bean_seq; + +create table bar ( + bar_type varchar(31) not null, + bar_id integer not null, + foo_id integer not null, + version integer not null, + constraint pk_bar primary key (bar_id) +); +create sequence bar_seq; + +create table oto_account ( + id bigint not null, + name varchar(255), version bigint not null, when_created timestamp not null, when_modified timestamp not null, + constraint pk_oto_account primary key (id) +); +create sequence oto_account_seq; + +create table o_address ( + id smallint not null, + line_1 varchar(100), + line_2 varchar(100), + city varchar(100), + cretime timestamp, + country_code varchar(2), + updtime timestamp not null, constraint pk_o_address primary key (id) ); +create sequence o_address_seq; -create table blob_holder ( +create table address ( + oid bigint not null, + street varchar(255), + version integer not null, + constraint pk_address primary key (oid) +); +create sequence address_seq; + +create table animals ( + species varchar(31) not null, id bigint not null, - text_content clob, - binary_content blob, - file_content blob, + shelter_id bigint, version bigint not null, - constraint pk_blob_holder primary key (id) + name varchar(255), + registration_number varchar(255), + date_of_birth date, + constraint pk_animals primary key (id) +); +create sequence animals_seq; + +create table animal_shelter ( + id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_animal_shelter primary key (id) +); +create sequence animal_shelter_seq; + +create table article ( + id integer not null, + name varchar(255), + author varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_article primary key (id) +); +create sequence article_seq; + +create table attribute ( + option_type integer(31) not null, + id integer not null, + attribute_holder_id integer, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_attribute primary key (id) +); +create sequence attribute_seq; + +create table attribute_holder ( + id integer not null, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_attribute_holder primary key (id) +); +create sequence attribute_holder_seq; + +create table audit_log ( + id bigint not null, + description varchar(255), + modified_description varchar(255), + constraint pk_audit_log primary key (id) +); +create sequence audit_log_seq; + +create table bbookmark ( + id integer not null, + bookmark_reference varchar(255), + user_id integer, + constraint pk_bbookmark primary key (id) +); +create sequence bbookmark_seq; + +create table bbookmark_user ( + id integer not null, + name varchar(255), + password varchar(255), + email_address varchar(255), + country varchar(255), + constraint pk_bbookmark_user primary key (id) +); +create sequence bbookmark_user_seq; + +create table bsimple_with_gen ( + id integer not null, + name varchar(255), + constraint pk_bsimple_with_gen primary key (id) +); +create sequence bsimple_with_gen_seq; + +create table bwith_qident ( + id integer not null, + "Name" varchar(255), + last_updated timestamp not null, + constraint uq_bwith_qident_name unique ("Name"), + constraint pk_bwith_qident primary key (id) +); +create sequence bwith_qident_seq; + +create table basic_joda_entity ( + id bigint not null, + name varchar(255), + created timestamp not null, + updated timestamp not null, + version timestamp not null, + constraint pk_basic_joda_entity primary key (id) +); +create sequence basic_joda_entity_seq; + +create table bean_with_time_zone ( + id bigint not null, + name varchar(255), + timezone varchar(20), + constraint pk_bean_with_time_zone primary key (id) +); +create sequence bean_with_time_zone_seq; + +create table drel_booking ( + id bigint not null, + agent_invoice bigint, + client_invoice bigint, + version integer not null, + constraint uq_drel_booking_agent_invoice unique (agent_invoice), + constraint uq_drel_booking_client_invoice unique (client_invoice), + constraint pk_drel_booking primary key (id) +); +create sequence drel_booking_seq; + +create table ckey_assoc ( + id integer not null, + assoc_one varchar(255), + constraint pk_ckey_assoc primary key (id) +); +create sequence ckey_assoc_seq; + +create table ckey_detail ( + id integer not null, + something varchar(255), + one_key integer, + two_key varchar(255), + constraint pk_ckey_detail primary key (id) +); +create sequence ckey_detail_seq; + +create table ckey_parent ( + one_key integer not null, + two_key varchar(255) not null, + name varchar(255), + assoc_id integer, + version integer not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); +create sequence ckey_parent_seq; + +create table calculation_result ( + ID integer not null, + charge double, + product_configuration_ID integer, + group_configuration_ID integer, + constraint pk_calculation_result primary key (ID) +); +create sequence calculation_result_seq; + +create table cao_bean ( + x_cust_id integer not null, + x_type_id integer not null, + description varchar(255), + version bigint not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); +create sequence cao_bean_seq; + +create table sa_car ( + id bigint not null, + version integer not null, + constraint pk_sa_car primary key (id) +); +create sequence sa_car_seq; + +create table sp_car_car ( + id bigint not null, + version integer not null, + constraint pk_sp_car_car primary key (id) +); +create sequence sp_car_car_seq; + +create table sp_car_car_wheels ( + car bigint not null, + wheel bigint not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) ); create table car_accessory ( - id bigint not null, + id integer not null, name varchar(255), - car_id bigint, + car_id integer, + cretime timestamp not null, + updtime timestamp not null, version bigint not null, - when_created timestamp not null, - when_modified timestamp not null, constraint pk_car_accessory primary key (id) ); +create sequence car_accessory_seq; -create table be_contact ( - id bigint not null, - first_name varchar(50), - last_name varchar(50), - email varchar(200), - phone varchar(20), - customer_id bigint not null, - version bigint not null, - when_created timestamp not null, - when_modified timestamp not null, - constraint pk_be_contact primary key (id) +create table configuration ( + type varchar(31) not null, + ID integer not null, + name varchar(255), + configurations_ID integer, + group_name varchar(255), + product_name varchar(255), + constraint pk_configuration primary key (ID) ); +create sequence configuration_seq; + +create table configurations ( + ID integer not null, + constraint pk_configurations primary key (ID) +); +create sequence configurations_seq; + +create table contact ( + id integer not null, + first_name varchar(255), + last_name varchar(255), + phone varchar(255), + mobile varchar(255), + email varchar(255), + customer_id integer not null, + group_id integer, + cretime timestamp not null, + updtime timestamp not null, + constraint pk_contact primary key (id) +); +create sequence contact_seq; + +create table contact_group ( + id integer not null, + name varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_contact_group primary key (id) +); +create sequence contact_group_seq; create table contact_note ( - id bigint not null, - contact_id bigint not null, + id integer not null, + contact_id integer, title varchar(255), note clob, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_contact_note primary key (id) +); +create sequence contact_note_seq; + +create table c_conversation ( + id bigint not null, + title varchar(255), + isopen boolean, + group_id bigint, version bigint not null, when_created timestamp not null, when_modified timestamp not null, - constraint pk_contact_note primary key (id) + constraint pk_c_conversation primary key (id) ); +create sequence c_conversation_seq; create table o_country ( code varchar(2) not null, name varchar(60), constraint pk_o_country primary key (code) ); +create sequence o_country_seq; -create table be_customer ( +create table o_customer ( + id integer not null, + status varchar(1), + name varchar(40) not null, + smallnote varchar(100), + anniversary date, + billing_address_id smallint, + shipping_address_id smallint, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint ck_o_customer_status check (status in ('N','A','I')), + constraint pk_o_customer primary key (id) +); +create sequence o_customer_seq; + +create table dexh_entity ( + oid bigint not null, + exhange_rate decimal(38), + exhange_cmoney_amount decimal(38), + exhange_cmoney_currency varchar(3), + last_updated timestamp not null, + constraint pk_dexh_entity primary key (oid) +); +create sequence dexh_entity_seq; + +create table dperson ( id bigint not null, - inactive boolean, - name varchar(100), - registered timestamp, - comments varchar(1000), - billing_address_id bigint, - shipping_address_id bigint, + first_name varchar(255), + last_name varchar(255), + salary decimal(38), + a_amt decimal(38), + a_curr varchar(3), + i_start timestamp, + i_end timestamp, + constraint pk_dperson primary key (id) +); +create sequence dperson_seq; + +create table rawinherit_data ( + id bigint not null, + number integer, + constraint pk_rawinherit_data primary key (id) +); +create sequence rawinherit_data_seq; + +create table e_basic ( + id integer not null, + status varchar(1), + name varchar(255), + description varchar(255), + some_date timestamp, + constraint ck_e_basic_status check (status in ('N','A','I')), + constraint pk_e_basic primary key (id) +); +create sequence e_basic_seq; + +create table ebasic_clob ( + id bigint not null, + name varchar(255), + title varchar(255), + description clob, + last_update timestamp not null, + constraint pk_ebasic_clob primary key (id) +); +create sequence ebasic_clob_seq; + +create table ebasic_clob_fetch_eager ( + id bigint not null, + name varchar(255), + title varchar(255), + description clob, + last_update timestamp not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); +create sequence ebasic_clob_fetch_eager_seq; + +create table ebasic_clob_no_ver ( + id bigint not null, + name varchar(255), + description clob, + constraint pk_ebasic_clob_no_ver primary key (id) +); +create sequence ebasic_clob_no_ver_seq; + +create table e_basicenc ( + id integer not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + last_update timestamp, + constraint pk_e_basicenc primary key (id) +); +create sequence e_basicenc_seq; + +create table e_basicenc_bin ( + id integer not null, + name varchar(255), + description varchar(255), + data blob, + some_time timestamp, + last_update timestamp not null, + constraint pk_e_basicenc_bin primary key (id) +); +create sequence e_basicenc_bin_seq; + +create table e_basic_enum_id ( + status varchar(1) not null, + name varchar(255), + description varchar(255), + constraint ck_e_basic_enum_id_status check (status in ('N','A','I')), + constraint pk_e_basic_enum_id primary key (status) +); +create sequence e_basic_enum_id_seq; + +create table ebasic_json_map ( + id bigint not null, + name varchar(255), + content clob, + version bigint not null, + constraint pk_ebasic_json_map primary key (id) +); +create sequence ebasic_json_map_seq; + +create table ebasic_json_map_blob ( + id bigint not null, + name varchar(255), + content blob, + version bigint not null, + constraint pk_ebasic_json_map_blob primary key (id) +); +create sequence ebasic_json_map_blob_seq; + +create table ebasic_json_map_json_b ( + id bigint not null, + name varchar(255), + content clob, + version bigint not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); +create sequence ebasic_json_map_json_b_seq; + +create table ebasic_json_map_varchar ( + id bigint not null, + name varchar(255), + content varchar(3000), + version bigint not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); +create sequence ebasic_json_map_varchar_seq; + +create table ebasic_json_node ( + id bigint not null, + name varchar(255), + content clob, + version bigint not null, + constraint pk_ebasic_json_node primary key (id) +); +create sequence ebasic_json_node_seq; + +create table ebasic_json_node_blob ( + id bigint not null, + name varchar(255), + content blob, + version bigint not null, + constraint pk_ebasic_json_node_blob primary key (id) +); +create sequence ebasic_json_node_blob_seq; + +create table ebasic_json_node_json_b ( + id bigint not null, + name varchar(255), + content clob, + version bigint not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); +create sequence ebasic_json_node_json_b_seq; + +create table ebasic_json_node_varchar ( + id bigint not null, + name varchar(255), + content varchar(1000), + version bigint not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); +create sequence ebasic_json_node_varchar_seq; + +create table e_basic_ndc ( + id integer not null, + name varchar(255), + constraint pk_e_basic_ndc primary key (id) +); +create sequence e_basic_ndc_seq; + +create table e_basicver ( + id integer not null, + name varchar(255), + description varchar(255), + other varchar(255), + last_update timestamp not null, + constraint pk_e_basicver primary key (id) +); +create sequence e_basicver_seq; + +create table e_basic_withlife ( + id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_e_basic_withlife primary key (id) +); +create sequence e_basic_withlife_seq; + +create table e_basicverucon ( + id integer not null, + name varchar(255), + other varchar(255), + other_one varchar(255), + description varchar(255), + last_update timestamp not null, + constraint uq_e_basicverucon_name unique (name), + constraint pk_e_basicverucon primary key (id) +); +create sequence e_basicverucon_seq; + +create table eemb_inner ( + id integer not null, + nome_inner varchar(255), + outer_id integer, + update_count integer not null, + constraint pk_eemb_inner primary key (id) +); +create sequence eemb_inner_seq; + +create table eemb_outer ( + id integer not null, + nome_outer varchar(255), + date1 timestamp, + date2 timestamp, + update_count integer not null, + constraint pk_eemb_outer primary key (id) +); +create sequence eemb_outer_seq; + +create table egen_props ( + id bigint not null, + name varchar(255), version bigint not null, when_created timestamp not null, when_modified timestamp not null, - constraint uq_be_customer_name unique (name), - constraint pk_be_customer primary key (id) + ts_created timestamp not null, + ts_updated timestamp not null, + ldt_created timestamp not null, + ldt_updated timestamp not null, + odt_created timestamp not null, + odt_updated timestamp not null, + zdt_created timestamp not null, + zdt_updated timestamp not null, + long_created bigint not null, + long_updated bigint not null, + constraint pk_egen_props primary key (id) +); +create sequence egen_props_seq; + +create table einvoice ( + id bigint not null, + date timestamp, + state integer, + person_id bigint, + ship_street varchar(255), + ship_suburb varchar(255), + ship_city varchar(255), + street varchar(255), + suburb varchar(255), + city varchar(255), + version bigint not null, + constraint ck_einvoice_state check (state in (0,1,2)), + constraint pk_einvoice primary key (id) +); +create sequence einvoice_seq; + +create table e_main ( + id integer not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_e_main primary key (id) +); +create sequence e_main_seq; + +create table enull_collection ( + id integer not null, + constraint pk_enull_collection primary key (id) +); +create sequence enull_collection_seq; + +create table enull_collection_detail ( + id integer not null, + enull_collection_id integer not null, + something varchar(255), + constraint pk_enull_collection_detail primary key (id) +); +create sequence enull_collection_detail_seq; + +create table eopt_one_a ( + id integer not null, + name_for_a varchar(255), + b_id integer, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_eopt_one_a primary key (id) +); +create sequence eopt_one_a_seq; + +create table eopt_one_b ( + id integer not null, + name_for_b varchar(255), + c_id integer not null, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_eopt_one_b primary key (id) +); +create sequence eopt_one_b_seq; + +create table eopt_one_c ( + id integer not null, + name_for_c varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_eopt_one_c primary key (id) +); +create sequence eopt_one_c_seq; + +create table eperson ( + id bigint not null, + name varchar(255), + notes varchar(255), + street varchar(255), + suburb varchar(255), + city varchar(255), + version bigint not null, + constraint pk_eperson primary key (id) +); +create sequence eperson_seq; + +create table esimple ( + usertypeid integer not null, + name varchar(255), + constraint pk_esimple primary key (usertypeid) ); -create table document ( +create table esome_type ( + id integer not null, + currency varchar(3), + locale varchar(20), + time_zone varchar(20), + constraint pk_esome_type primary key (id) +); +create sequence esome_type_seq; + +create table etrans_many ( + id integer not null, + name varchar(255), + constraint pk_etrans_many primary key (id) +); +create sequence etrans_many_seq; + +create table evanilla_collection ( + id integer not null, + constraint pk_evanilla_collection primary key (id) +); +create sequence evanilla_collection_seq; + +create table evanilla_collection_detail ( + id integer not null, + evanilla_collection_id integer not null, + something varchar(255), + constraint pk_evanilla_collection_detail primary key (id) +); +create sequence evanilla_collection_detail_seq; + +create table ewho_props ( + id bigint not null, + name varchar(255), + who_created varchar(255) not null, + who_modified varchar(255) not null, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_ewho_props primary key (id) +); +create sequence ewho_props_seq; + +create table e_withinet ( + id bigint not null, + name varchar(255), + inet_address varchar(50), + version bigint not null, + constraint pk_e_withinet primary key (id) +); +create sequence e_withinet_seq; + +create table td_child ( + child_id integer not null, + child_name varchar(255), + parent_id integer not null, + constraint pk_td_child primary key (child_id) +); +create sequence td_child_seq; + +create table td_parent ( + parent_type varchar(31) not null, + parent_id integer not null, + parent_name varchar(255), + extended_name varchar(255), + constraint pk_td_parent primary key (parent_id) +); +create sequence td_parent_seq; + +create table feature_desc ( + id integer not null, + name varchar(255), + description varchar(255), + constraint pk_feature_desc primary key (id) +); +create sequence feature_desc_seq; + +create table f_first ( + id bigint not null, + name varchar(255), + constraint pk_f_first primary key (id) +); +create sequence f_first_seq; + +create table foo ( + foo_id integer not null, + important_text varchar(255), + version integer not null, + constraint pk_foo primary key (foo_id) +); +create sequence foo_seq; + +create table gen_key_identity ( + id bigint not null, + description varchar(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id bigint not null, + description varchar(255), + constraint pk_gen_key_sequence primary key (id) +); +create sequence SEQ; + +create table gen_key_table ( + id bigint not null, + description varchar(255), + constraint pk_gen_key_table primary key (id) +); +create sequence gen_key_table_seq; + +create table c_group ( + id bigint not null, + inactive boolean, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_c_group primary key (id) +); +create sequence c_group_seq; + +create table imrelated ( + id bigint not null, + name varchar(255), + owner_id bigint not null, + constraint pk_imrelated primary key (id) +); +create sequence imrelated_seq; + +create table imroot ( + dtype varchar(10) not null, id bigint not null, title varchar(255), - author varchar(255), - content clob, - version bigint not null, - constraint pk_document primary key (id) + when_title timestamp, + name varchar(255), + constraint pk_imroot primary key (id) ); +create sequence imroot_seq; + +create table ixresource ( + dtype varchar(255), + id binary(16) not null, + name varchar(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_info_company primary key (id) +); +create sequence info_company_seq; + +create table info_contact ( + id bigint not null, + name varchar(255), + company_id bigint not null, + version bigint not null, + constraint pk_info_contact primary key (id) +); +create sequence info_contact_seq; + +create table info_customer ( + id bigint not null, + name varchar(255), + company_id bigint, + version bigint not null, + constraint uq_info_customer_company_id unique (company_id), + constraint pk_info_customer primary key (id) +); +create sequence info_customer_seq; + +create table inner_report ( + id bigint not null, + name varchar(255), + forecast_id bigint, + constraint uq_inner_report_forecast_id unique (forecast_id), + constraint pk_inner_report primary key (id) +); +create sequence inner_report_seq; + +create table drel_invoice ( + id bigint not null, + booking bigint, + version integer not null, + constraint pk_drel_invoice primary key (id) +); +create sequence drel_invoice_seq; + +create table item ( + customer integer, + itemNumber varchar(255) not null, + description varchar(255), + units varchar(255), + type integer, + region integer, + DATE_MODIFIED timestamp, + DATE_CREATED timestamp, + MODIFIED_BY varchar(255), + CREATED_BY varchar(255), + version bigint not null, + constraint pk_item primary key (itemNumber) +); +create sequence item_seq; + +create table level1 ( + id bigint not null, + name varchar(255), + constraint pk_level1 primary key (id) +); +create sequence level1_seq; + +create table level1_level4 ( + level1_id bigint not null, + level4_id bigint not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id bigint not null, + level2_id bigint not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id bigint not null, + name varchar(255), + constraint pk_level2 primary key (id) +); +create sequence level2_seq; + +create table level2_level3 ( + level2_id bigint not null, + level3_id bigint not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id bigint not null, + name varchar(255), + constraint pk_level3 primary key (id) +); +create sequence level3_seq; + +create table level4 ( + id bigint not null, + name varchar(255), + constraint pk_level4 primary key (id) +); +create sequence level4_seq; + +create table la_attr_value ( + id integer not null, + name varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_la_attr_value primary key (id) +); +create sequence la_attr_value_seq; + +create table la_attr_value_attribute ( + la_attr_value_id integer not null, + attribute_id integer not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table mmedia ( + type varchar(31) not null, + id bigint not null, + url varchar(255), + note varchar(255), + constraint pk_mmedia primary key (id) +); +create sequence mmedia_seq; + +create table non_updateprop ( + id integer not null, + non_enum varchar(5), + name varchar(255), + note varchar(255), + constraint ck_non_updateprop_non_enum check (non_enum in ('BEGIN','END')), + constraint pk_non_updateprop primary key (id) +); +create sequence non_updateprop_seq; + +create table mprinter ( + id bigint not null, + name varchar(255), + flags bigint not null, + current_state_id bigint, + last_swap_cyan_id bigint, + last_swap_magenta_id bigint, + last_swap_yellow_id bigint, + last_swap_black_id bigint, + version bigint not null, + constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), + constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), + constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), + constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), + constraint pk_mprinter primary key (id) +); +create sequence mprinter_seq; + +create table mprinter_state ( + id bigint not null, + flags bigint, + printer_id bigint, + version bigint not null, + constraint pk_mprinter_state primary key (id) +); +create sequence mprinter_state_seq; + +create table mprofile ( + id bigint not null, + picture_id bigint, + name varchar(255), + constraint pk_mprofile primary key (id) +); +create sequence mprofile_seq; + +create table mprotected_construct_bean ( + id bigint not null, + name varchar(255), + constraint pk_mprotected_construct_bean primary key (id) +); +create sequence mprotected_construct_bean_seq; create table mrole ( - id integer not null, + roleid integer not null, role_name varchar(255), - constraint pk_mrole primary key (id) + constraint pk_mrole primary key (roleid) ); +create sequence mrole_seq; create table mrole_muser ( - mrole_id integer not null, - muser_id integer not null, - constraint pk_mrole_muser primary key (mrole_id,muser_id) + mrole_roleid integer not null, + muser_userid integer not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) ); +create table msome_other ( + id bigint not null, + name varchar(255), + constraint pk_msome_other primary key (id) +); +create sequence msome_other_seq; + create table muser ( - id integer not null, + userid integer not null, user_name varchar(255), user_type_id integer, - constraint pk_muser primary key (id) + constraint pk_muser primary key (userid) ); +create sequence muser_seq; create table muser_type ( id integer not null, name varchar(255), constraint pk_muser_type primary key (id) ); +create sequence muser_type_seq; -create table o_booking ( +create table map_super_actual ( id bigint not null, - booking_date date, - invoice_id bigint, - constraint uq_o_booking_invoice_id unique (invoice_id), - constraint pk_o_booking primary key (id) + name varchar(255), + when_created timestamp not null, + when_updated timestamp not null, + constraint pk_map_super_actual primary key (id) +); +create sequence map_super_actual_seq; + +create table c_message ( + id bigint not null, + title varchar(255), + body varchar(255), + conversation_id bigint, + user_id bigint, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_c_message primary key (id) +); +create sequence c_message_seq; + +create table mnoc_role ( + role_id integer not null, + role_name varchar(255), + version integer not null, + constraint pk_mnoc_role primary key (role_id) +); +create sequence mnoc_role_seq; + +create table mnoc_user ( + user_id integer not null, + user_name varchar(255), + version integer not null, + constraint pk_mnoc_user primary key (user_id) +); +create sequence mnoc_user_seq; + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id integer not null, + mnoc_role_role_id integer not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) ); -create table o_invoice ( +create table mp_role ( id bigint not null, - invoice_date date, - constraint pk_o_invoice primary key (id) + mp_user_id bigint not null, + code varchar(255), + organization_id bigint, + constraint pk_mp_role primary key (id) +); +create sequence mp_role_seq; + +create table mp_user ( + id bigint not null, + name varchar(255), + constraint pk_mp_user primary key (id) +); +create sequence mp_user_seq; + +create table my_lob_size ( + id integer not null, + name varchar(255), + my_count integer, + my_lob clob, + constraint pk_my_lob_size primary key (id) +); +create sequence my_lob_size_seq; + +create table my_lob_size_join_many ( + id integer not null, + something varchar(255), + other varchar(255), + parent_id integer, + constraint pk_my_lob_size_join_many primary key (id) +); +create sequence my_lob_size_join_many_seq; + +create table noidbean ( + name varchar(255), + subject varchar(255), + when_created timestamp not null +); + +create table o_cached_bean ( + id bigint not null, + name varchar(255), + constraint pk_o_cached_bean primary key (id) +); +create sequence o_cached_bean_seq; + +create table o_cached_bean_country ( + o_cached_bean_id bigint not null, + o_country_code varchar(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id bigint not null, + cached_bean_id bigint, + constraint pk_o_cached_bean_child primary key (id) +); +create sequence o_cached_bean_child_seq; + +create table ocar ( + id integer not null, + vin varchar(255), + name varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_ocar primary key (id) +); +create sequence ocar_seq; + +create table oengine ( + engine_id binary(16) not null, + short_desc varchar(255), + car_id integer, + version integer not null, + constraint uq_oengine_car_id unique (car_id), + constraint pk_oengine primary key (engine_id) +); + +create table ogear_box ( + id binary(16) not null, + box_desc varchar(255), + box_size integer, + car_id integer, + version integer not null, + constraint uq_ogear_box_car_id unique (car_id), + constraint pk_ogear_box primary key (id) ); create table o_order ( - id bigint not null, - status varchar(1), + id integer not null, + status integer, order_date date, ship_date date, - customer_id bigint, - shipping_address_id bigint, - version bigint not null, - when_created timestamp not null, - when_modified timestamp not null, - constraint ck_o_order_status check (status in ('N','C','A','S')), + kcustomer_id integer not null, + cretime timestamp not null, + updtime timestamp not null, + constraint ck_o_order_status check (status in (0,1,2,3)), constraint pk_o_order primary key (id) ); +create sequence o_order_seq; create table o_order_detail ( - id bigint not null, - order_id bigint, + id integer not null, + order_id integer, order_qty integer, ship_qty integer, unit_price double, - product_id bigint, - version bigint not null, - when_created timestamp not null, - when_modified timestamp not null, + product_id integer, + cretime timestamp, + updtime timestamp not null, constraint pk_o_order_detail primary key (id) ); +create sequence o_order_detail_seq; -create table o_product ( - id bigint not null, - sku varchar(20), +create table s_orders ( + uuid varchar(255) not null, + constraint pk_s_orders primary key (uuid) +); +create sequence s_orders_seq; + +create table s_order_items ( + uuid varchar(255) not null, + product_variant_uuid varchar(255), + order_uuid varchar(255), + quantity integer, + amount decimal(38), + constraint pk_s_order_items primary key (uuid) +); +create sequence s_order_items_seq; + +create table or_order_ship ( + id integer not null, + order_id integer, + ship_time timestamp, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_or_order_ship primary key (id) +); +create sequence or_order_ship_seq; + +create table oto_child ( + id integer not null, name varchar(255), + master_id bigint, + constraint uq_oto_child_master_id unique (master_id), + constraint pk_oto_child primary key (id) +); +create sequence oto_child_seq; + +create table oto_master ( + id bigint not null, + name varchar(255), + constraint pk_oto_master primary key (id) +); +create sequence oto_master_seq; + +create table pfile ( + id integer not null, + name varchar(255), + file_content_id integer, + file_content2_id integer, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint uq_pfile_file_content_id unique (file_content_id), + constraint uq_pfile_file_content2_id unique (file_content2_id), + constraint pk_pfile primary key (id) +); +create sequence pfile_seq; + +create table pfile_content ( + id integer not null, + content blob, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_pfile_content primary key (id) +); +create sequence pfile_content_seq; + +create table paggview ( + pview_id binary(16), + amount integer not null, + constraint uq_paggview_pview_id unique (pview_id) +); + +create table pallet_location ( + type varchar(31) not null, + ID integer not null, + ZONE_SID integer not null, + attribute varchar(255), + constraint pk_pallet_location primary key (ID) +); +create sequence pallet_location_seq; + +create table parcel ( + parcelId bigint not null, + description varchar(255), + constraint pk_parcel primary key (parcelId) +); +create sequence parcel_seq; + +create table parcel_location ( + parcelLocId bigint not null, + location varchar(255), + parcelId bigint, + constraint uq_parcel_location_parcelid unique (parcelId), + constraint pk_parcel_location primary key (parcelLocId) +); +create sequence parcel_location_seq; + +create table rawinherit_parent ( + type varchar(31) not null, + id bigint not null, + number integer, + constraint pk_rawinherit_parent primary key (id) +); +create sequence rawinherit_parent_seq; + +create table rawinherit_parent_rawinherit_dat ( + rawinherit_parent_id bigint not null, + rawinherit_data_id bigint not null, + constraint pk_rawinherit_parent_rawinherit_dat primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table c_participation ( + id bigint not null, + rating integer, + type integer, + conversation_id bigint not null, + user_id bigint not null, version bigint not null, when_created timestamp not null, when_modified timestamp not null, + constraint ck_c_participation_type check (type in (0,1)), + constraint pk_c_participation primary key (id) +); +create sequence c_participation_seq; + +create table mt_permission ( + id binary(16) not null, + name varchar(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id integer not null, + name varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_persistent_file primary key (id) +); +create sequence persistent_file_seq; + +create table persistent_file_content ( + id integer not null, + persistent_file_id integer, + content blob, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), + constraint pk_persistent_file_content primary key (id) +); +create sequence persistent_file_content_seq; + +create table PERSONS ( + ID bigint not null, + SURNAME varchar(64) not null, + NAME varchar(64) not null, + constraint pk_persons primary key (ID) +); +create sequence PERSONS_seq start with 1000 increment by 40; + +create table person ( + oid bigint not null, + default_address_oid bigint, + version integer not null, + constraint pk_person primary key (oid) +); +create sequence person_seq; + +create table PHONES ( + ID bigint not null, + PHONE_NUMBER varchar(7) not null, + PERSON_ID bigint not null, + constraint uq_phones_phone_number unique (PHONE_NUMBER), + constraint pk_phones primary key (ID) +); +create sequence PHONES_seq; + +create table o_product ( + id integer not null, + sku varchar(20), + name varchar(255), + cretime timestamp not null, + updtime timestamp not null, constraint pk_o_product primary key (id) ); +create sequence o_product_seq; + +create table pp ( + id binary(16) not null, + name varchar(255), + value varchar(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id binary(16) not null, + ww_id binary(16) not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table rcustomer ( + company varchar(255) not null, + name varchar(255) not null, + description varchar(255), + constraint pk_rcustomer primary key (company,name) +); +create sequence rcustomer_seq; + +create table r_orders ( + company varchar(255), + order_number integer not null, + customerName varchar(255), + item varchar(255), + constraint pk_r_orders primary key (order_number) +); +create sequence r_orders_seq; + +create table region ( + customer integer not null, + type integer not null, + description varchar(255), + version bigint not null, + constraint pk_region primary key (customer,type) +); +create sequence region_seq; + +create table ResourceFile ( + id varchar(64) not null, + parentResourceFileId varchar(64), + name varchar(128) not null, + constraint pk_resourcefile primary key (id) +); +create sequence ResourceFile_seq; + +create table mt_role ( + id binary(16) not null, + name varchar(50), + tenant_id binary(16), + version bigint not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id binary(16) not null, + mt_permission_id binary(16) not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id bigint not null, + name varchar(255), + constraint pk_em_role primary key (id) +); +create sequence em_role_seq; + +create table f_second ( + id bigint not null, + first bigint, + title varchar(255), + constraint uq_f_second_first unique (first), + constraint pk_f_second primary key (id) +); +create sequence f_second_seq; + +create table section ( + id integer not null, + article_id integer, + type integer, + content clob, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint ck_section_type check (type in (0,1)), + constraint pk_section primary key (id) +); +create sequence section_seq; + +create table self_parent ( + id bigint not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_self_parent primary key (id) +); +create sequence self_parent_seq; + +create table self_ref_customer ( + id bigint not null, + name varchar(255), + referred_by_id bigint, + constraint pk_self_ref_customer primary key (id) +); +create sequence self_ref_customer_seq; + +create table self_ref_example ( + id bigint not null, + name varchar(255) not null, + parent_id bigint, + constraint pk_self_ref_example primary key (id) +); +create sequence self_ref_example_seq; + +create table some_enum_bean ( + id bigint not null, + some_enum integer, + name varchar(255), + constraint ck_some_enum_bean_some_enum check (some_enum in (0,1)), + constraint pk_some_enum_bean primary key (id) +); +create sequence some_enum_bean_seq; + +create table some_file_bean ( + id bigint not null, + name varchar(255), + content blob, + version bigint not null, + constraint pk_some_file_bean primary key (id) +); +create sequence some_file_bean_seq; + +create table some_new_types_bean ( + id bigint not null, + dow integer(1), + mth integer(1), + yr integer, + yr_mth date, + local_date date, + local_date_time timestamp, + offset_date_time timestamp, + zoned_date_time timestamp, + instant timestamp, + zone_id varchar(60), + zone_offset varchar(60), + version bigint not null, + constraint ck_some_new_types_bean_dow check (dow in ('1','2','3','4','5','6','7')), + constraint ck_some_new_types_bean_mth check (mth in ('1','2','3','4','5','6','7','8','9','10','11','12')), + constraint pk_some_new_types_bean primary key (id) +); +create sequence some_new_types_bean_seq; + +create table some_period_bean ( + id bigint not null, + period_years integer, + period_months integer, + period_days integer, + anniversary date, + version bigint not null, + constraint pk_some_period_bean primary key (id) +); +create sequence some_period_bean_seq; + +create table stockforecast ( + type varchar(31) not null, + id bigint not null, + inner_report_id bigint, + constraint pk_stockforecast primary key (id) +); +create sequence stockforecast_seq; + +create table sub_section ( + id integer not null, + section_id integer, + title varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_sub_section primary key (id) +); +create sequence sub_section_seq; + +create table sub_type ( + sub_type_id integer not null, + description varchar(255), + version bigint not null, + constraint pk_sub_type primary key (sub_type_id) +); +create sequence sub_type_seq; + +create table tbytes_only ( + id integer not null, + content blob, + constraint pk_tbytes_only primary key (id) +); +create sequence tbytes_only_seq; + +create table tcar ( + type varchar(31) not null, + plate_no varchar(255) not null, + truckLoad bigint, + constraint pk_tcar primary key (plate_no) +); +create sequence tcar_seq; + +create table tint_root ( + my_type integer(3) not null, + id integer not null, + name varchar(255), + child_property varchar(255), + constraint pk_tint_root primary key (id) +); +create sequence tint_root_seq; + +create table tjoda_entity ( + id integer not null, + local_time time, + constraint pk_tjoda_entity primary key (id) +); +create sequence tjoda_entity_seq; + +create table t_mapsuper1 ( + id integer not null, + something varchar(255), + name varchar(255), + version integer not null, + constraint pk_t_mapsuper1 primary key (id) +); +create sequence t_mapsuper1_seq; + +create table t_oneb ( + id integer not null, + name varchar(255), + description varchar(255), + active boolean, + constraint pk_t_oneb primary key (id) +); +create sequence t_oneb_seq; + +create table t_detail_with_other_namexxxyy ( + id integer not null, + name varchar(255), + description varchar(255), + active boolean, + master_id integer, + constraint pk_t_detail_with_other_namexxxyy primary key (id) +); +create sequence t_atable_detail_seq; + +create table ts_detail_two ( + id integer not null, + name varchar(255), + description varchar(255), + active boolean, + master_id integer, + constraint pk_ts_detail_two primary key (id) +); +create sequence ts_detail_two_seq; + +create table t_atable_thatisrelatively ( + id integer not null, + name varchar(255), + description varchar(255), + active boolean, + constraint pk_t_atable_thatisrelatively primary key (id) +); +create sequence t_atable_master_seq; + +create table ts_master_two ( + id integer not null, + name varchar(255), + description varchar(255), + active boolean, + constraint pk_ts_master_two primary key (id) +); +create sequence ts_master_two_seq; + +create table tuuid_entity ( + id binary(16) not null, + name varchar(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id bigint not null, + owner_plate_no varchar(255) not null, + constraint pk_twheel primary key (id) +); +create sequence twheel_seq; + +create table twith_pre_insert ( + id integer not null, + name varchar(255) not null, + title varchar(255), + constraint pk_twith_pre_insert primary key (id) +); +create sequence twith_pre_insert_seq; + +create table mt_tenant ( + id binary(16) not null, + name varchar(255), + version bigint not null, + constraint pk_mt_tenant primary key (id) +); + +create table sa_tire ( + id bigint not null, + version integer not null, + constraint pk_sa_tire primary key (id) +); +create sequence sa_tire_seq; + +create table tire ( + id bigint not null, + wheel bigint, + version integer not null, + constraint uq_tire_wheel unique (wheel), + constraint pk_tire primary key (id) +); +create sequence tire_seq; + +create table trip ( + id integer not null, + vehicle_driver_id integer, + destination varchar(255), + address_id smallint, + star_date timestamp, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_trip primary key (id) +); +create sequence trip_seq; create table truck_ref ( id integer not null, something varchar(255), constraint pk_truck_ref primary key (id) ); +create sequence truck_ref_seq; -create table vehicle ( - dtype varchar(3) not null, +create table type ( + customer integer not null, + type integer not null, + description varchar(255), + sub_type_id integer, + version bigint not null, + constraint pk_type primary key (customer,type) +); +create sequence type_seq; + +create table ut_detail ( + id integer not null, + utmaster_id integer not null, + name varchar(255), + qty integer, + amount double, + version integer not null, + constraint pk_ut_detail primary key (id) +); +create sequence ut_detail_seq; + +create table ut_master ( + id integer not null, + name varchar(255), + description varchar(255), + version integer not null, + constraint pk_ut_master primary key (id) +); +create sequence ut_master_seq; + +create table uuone ( + id binary(16) not null, + name varchar(255), + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id binary(16) not null, + name varchar(255), + master_id binary(16), + constraint pk_uutwo primary key (id) +); + +create table em_user ( id bigint not null, - license_number varchar(255), - registration_date timestamp, + name varchar(255), + constraint pk_em_user primary key (id) +); +create sequence em_user_seq; + +create table tx_user ( + id bigint not null, + name varchar(255), + constraint pk_tx_user primary key (id) +); +create sequence tx_user_seq; + +create table c_user ( + id bigint not null, + inactive boolean, + name varchar(255), + email varchar(255), + group_id bigint, version bigint not null, when_created timestamp not null, when_modified timestamp not null, + constraint pk_c_user primary key (id) +); +create sequence c_user_seq; + +create table oto_user ( + id bigint not null, + name varchar(255), + account_id bigint not null, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); +create sequence oto_user_seq; + +create table em_user_role ( + user_id bigint not null, + role_id bigint not null +); +create sequence em_user_role_seq; + +create table vehicle ( + dtype varchar(3) not null, + id integer not null, + license_number varchar(255), + registration_date timestamp, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, truck_ref_id integer, capacity double, driver varchar(255), car_ref_id integer, constraint pk_vehicle primary key (id) ); +create sequence vehicle_seq; + +create table vehicle_driver ( + id integer not null, + name varchar(255), + vehicle_id integer, + address_id smallint, + license_issued_on timestamp, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_vehicle_driver primary key (id) +); +create sequence vehicle_driver_seq; + +create table warehouses ( + ID integer not null, + officeZoneId integer, + constraint pk_warehouses primary key (ID) +); +create sequence warehouses_seq; + +create table WarehousesShippingZones ( + warehouseId integer not null, + shippingZoneId integer not null, + constraint pk_warehousesshippingzones primary key (warehouseId,shippingZoneId) +); + +create table sa_wheel ( + id bigint not null, + tire bigint, + car bigint, + version integer not null, + constraint pk_sa_wheel primary key (id) +); +create sequence sa_wheel_seq; + +create table sp_car_wheel ( + id bigint not null, + version integer not null, + constraint pk_sp_car_wheel primary key (id) +); +create sequence sp_car_wheel_seq; + +create table wheel ( + id bigint not null, + version integer not null, + constraint pk_wheel primary key (id) +); +create sequence wheel_seq; + +create table with_zero ( + id bigint not null, + name varchar(255), + parent_id integer, + version bigint not null, + constraint pk_with_zero primary key (id) +); +create sequence with_zero_seq; + +create table parent ( + id integer not null, + constraint pk_parent primary key (id) +); +create sequence parent_seq; + +create table wview ( + id binary(16) not null, + name varchar(255) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type varchar(31) not null, + ID integer not null, + attribute varchar(255), + constraint pk_zones primary key (ID) +); +create sequence zones_seq; diff --git a/src/test/resources/assert/changeset-rollback.txt b/src/test/resources/assert/changeset-rollback.txt index 42b1af137..db6860ab9 100644 --- a/src/test/resources/assert/changeset-rollback.txt +++ b/src/test/resources/assert/changeset-rollback.txt @@ -1,38 +1,424 @@ +drop table asimple_bean; +drop sequence asimple_bean_seq; +drop table bar; +drop sequence bar_seq; +drop table oto_account; +drop sequence oto_account_seq; drop table o_address; - -drop table blob_holder; +drop sequence o_address_seq; +drop table address; +drop sequence address_seq; +drop table animals; +drop sequence animals_seq; +drop table animal_shelter; +drop sequence animal_shelter_seq; +drop table article; +drop sequence article_seq; +drop table attribute; +drop sequence attribute_seq; +drop table attribute_holder; +drop sequence attribute_holder_seq; +drop table audit_log; +drop sequence audit_log_seq; +drop table bbookmark; +drop sequence bbookmark_seq; +drop table bbookmark_user; +drop sequence bbookmark_user_seq; +drop table bsimple_with_gen; +drop sequence bsimple_with_gen_seq; +drop table bwith_qident; +drop sequence bwith_qident_seq; +drop table basic_joda_entity; +drop sequence basic_joda_entity_seq; +drop table bean_with_time_zone; +drop sequence bean_with_time_zone_seq; +drop table drel_booking; +drop sequence drel_booking_seq; +drop table ckey_assoc; +drop sequence ckey_assoc_seq; +drop table ckey_detail; +drop sequence ckey_detail_seq; +drop table ckey_parent; +drop sequence ckey_parent_seq; +drop table calculation_result; +drop sequence calculation_result_seq; +drop table cao_bean; +drop sequence cao_bean_seq; +drop table sa_car; +drop sequence sa_car_seq; +drop table sp_car_car; +drop sequence sp_car_car_seq; +drop table sp_car_car_wheels; drop table car_accessory; - -drop table be_contact; - +drop sequence car_accessory_seq; +drop table configuration; +drop sequence configuration_seq; +drop table configurations; +drop sequence configurations_seq; +drop table contact; +drop sequence contact_seq; +drop table contact_group; +drop sequence contact_group_seq; drop table contact_note; - +drop sequence contact_note_seq; +drop table c_conversation; +drop sequence c_conversation_seq; drop table o_country; +drop sequence o_country_seq; +drop table o_customer; +drop sequence o_customer_seq; +drop table dexh_entity; +drop sequence dexh_entity_seq; +drop table dperson; +drop sequence dperson_seq; +drop table rawinherit_data; +drop sequence rawinherit_data_seq; +drop table e_basic; +drop sequence e_basic_seq; +drop table ebasic_clob; +drop sequence ebasic_clob_seq; +drop table ebasic_clob_fetch_eager; +drop sequence ebasic_clob_fetch_eager_seq; +drop table ebasic_clob_no_ver; +drop sequence ebasic_clob_no_ver_seq; +drop table e_basicenc; +drop sequence e_basicenc_seq; +drop table e_basicenc_bin; +drop sequence e_basicenc_bin_seq; +drop table e_basic_enum_id; +drop sequence e_basic_enum_id_seq; +drop table ebasic_json_map; +drop sequence ebasic_json_map_seq; +drop table ebasic_json_map_blob; +drop sequence ebasic_json_map_blob_seq; +drop table ebasic_json_map_json_b; +drop sequence ebasic_json_map_json_b_seq; +drop table ebasic_json_map_varchar; +drop sequence ebasic_json_map_varchar_seq; +drop table ebasic_json_node; +drop sequence ebasic_json_node_seq; +drop table ebasic_json_node_blob; +drop sequence ebasic_json_node_blob_seq; +drop table ebasic_json_node_json_b; +drop sequence ebasic_json_node_json_b_seq; +drop table ebasic_json_node_varchar; +drop sequence ebasic_json_node_varchar_seq; +drop table e_basic_ndc; +drop sequence e_basic_ndc_seq; +drop table e_basicver; +drop sequence e_basicver_seq; +drop table e_basic_withlife; +drop sequence e_basic_withlife_seq; +drop table e_basicverucon; +drop sequence e_basicverucon_seq; +drop table eemb_inner; +drop sequence eemb_inner_seq; +drop table eemb_outer; +drop sequence eemb_outer_seq; +drop table egen_props; +drop sequence egen_props_seq; +drop table einvoice; +drop sequence einvoice_seq; +drop table e_main; +drop sequence e_main_seq; +drop table enull_collection; +drop sequence enull_collection_seq; +drop table enull_collection_detail; +drop sequence enull_collection_detail_seq; +drop table eopt_one_a; +drop sequence eopt_one_a_seq; +drop table eopt_one_b; +drop sequence eopt_one_b_seq; +drop table eopt_one_c; +drop sequence eopt_one_c_seq; +drop table eperson; +drop sequence eperson_seq; +drop table esimple; -drop table be_customer; +drop table esome_type; +drop sequence esome_type_seq; +drop table etrans_many; +drop sequence etrans_many_seq; +drop table evanilla_collection; +drop sequence evanilla_collection_seq; +drop table evanilla_collection_detail; +drop sequence evanilla_collection_detail_seq; +drop table ewho_props; +drop sequence ewho_props_seq; +drop table e_withinet; +drop sequence e_withinet_seq; +drop table td_child; +drop sequence td_child_seq; +drop table td_parent; +drop sequence td_parent_seq; +drop table feature_desc; +drop sequence feature_desc_seq; +drop table f_first; +drop sequence f_first_seq; +drop table foo; +drop sequence foo_seq; +drop table gen_key_identity; -drop table document; +drop table gen_key_sequence; +drop sequence SEQ; +drop table gen_key_table; +drop sequence gen_key_table_seq; +drop table c_group; +drop sequence c_group_seq; +drop table imrelated; +drop sequence imrelated_seq; +drop table imroot; +drop sequence imroot_seq; +drop table ixresource; +drop table info_company; +drop sequence info_company_seq; +drop table info_contact; +drop sequence info_contact_seq; +drop table info_customer; +drop sequence info_customer_seq; +drop table inner_report; +drop sequence inner_report_seq; +drop table drel_invoice; +drop sequence drel_invoice_seq; +drop table item; +drop sequence item_seq; +drop table level1; +drop sequence level1_seq; +drop table level1_level4; + +drop table level1_level2; + +drop table level2; +drop sequence level2_seq; +drop table level2_level3; + +drop table level3; +drop sequence level3_seq; +drop table level4; +drop sequence level4_seq; +drop table la_attr_value; +drop sequence la_attr_value_seq; +drop table la_attr_value_attribute; + +drop table mmedia; +drop sequence mmedia_seq; +drop table non_updateprop; +drop sequence non_updateprop_seq; +drop table mprinter; +drop sequence mprinter_seq; +drop table mprinter_state; +drop sequence mprinter_state_seq; +drop table mprofile; +drop sequence mprofile_seq; +drop table mprotected_construct_bean; +drop sequence mprotected_construct_bean_seq; drop table mrole; - +drop sequence mrole_seq; drop table mrole_muser; +drop table msome_other; +drop sequence msome_other_seq; drop table muser; - +drop sequence muser_seq; drop table muser_type; +drop sequence muser_type_seq; +drop table map_super_actual; +drop sequence map_super_actual_seq; +drop table c_message; +drop sequence c_message_seq; +drop table mnoc_role; +drop sequence mnoc_role_seq; +drop table mnoc_user; +drop sequence mnoc_user_seq; +drop table mnoc_user_mnoc_role; -drop table o_booking; +drop table mp_role; +drop sequence mp_role_seq; +drop table mp_user; +drop sequence mp_user_seq; +drop table my_lob_size; +drop sequence my_lob_size_seq; +drop table my_lob_size_join_many; +drop sequence my_lob_size_join_many_seq; +drop table noidbean; -drop table o_invoice; +drop table o_cached_bean; +drop sequence o_cached_bean_seq; +drop table o_cached_bean_country; + +drop table o_cached_bean_child; +drop sequence o_cached_bean_child_seq; +drop table ocar; +drop sequence ocar_seq; +drop table oengine; + +drop table ogear_box; drop table o_order; - +drop sequence o_order_seq; drop table o_order_detail; +drop sequence o_order_detail_seq; +drop table s_orders; +drop sequence s_orders_seq; +drop table s_order_items; +drop sequence s_order_items_seq; +drop table or_order_ship; +drop sequence or_order_ship_seq; +drop table oto_child; +drop sequence oto_child_seq; +drop table oto_master; +drop sequence oto_master_seq; +drop table pfile; +drop sequence pfile_seq; +drop table pfile_content; +drop sequence pfile_content_seq; +drop table paggview; +drop table pallet_location; +drop sequence pallet_location_seq; +drop table parcel; +drop sequence parcel_seq; +drop table parcel_location; +drop sequence parcel_location_seq; +drop table rawinherit_parent; +drop sequence rawinherit_parent_seq; +drop table rawinherit_parent_rawinherit_dat; + +drop table c_participation; +drop sequence c_participation_seq; +drop table mt_permission; + +drop table persistent_file; +drop sequence persistent_file_seq; +drop table persistent_file_content; +drop sequence persistent_file_content_seq; +drop table PERSONS; +drop sequence PERSONS_seq; +drop table person; +drop sequence person_seq; +drop table PHONES; +drop sequence PHONES_seq; drop table o_product; +drop sequence o_product_seq; +drop table pp; +drop table pp_to_ww; + +drop table rcustomer; +drop sequence rcustomer_seq; +drop table r_orders; +drop sequence r_orders_seq; +drop table region; +drop sequence region_seq; +drop table ResourceFile; +drop sequence ResourceFile_seq; +drop table mt_role; + +drop table mt_role_permission; + +drop table em_role; +drop sequence em_role_seq; +drop table f_second; +drop sequence f_second_seq; +drop table section; +drop sequence section_seq; +drop table self_parent; +drop sequence self_parent_seq; +drop table self_ref_customer; +drop sequence self_ref_customer_seq; +drop table self_ref_example; +drop sequence self_ref_example_seq; +drop table some_enum_bean; +drop sequence some_enum_bean_seq; +drop table some_file_bean; +drop sequence some_file_bean_seq; +drop table some_new_types_bean; +drop sequence some_new_types_bean_seq; +drop table some_period_bean; +drop sequence some_period_bean_seq; +drop table stockforecast; +drop sequence stockforecast_seq; +drop table sub_section; +drop sequence sub_section_seq; +drop table sub_type; +drop sequence sub_type_seq; +drop table tbytes_only; +drop sequence tbytes_only_seq; +drop table tcar; +drop sequence tcar_seq; +drop table tint_root; +drop sequence tint_root_seq; +drop table tjoda_entity; +drop sequence tjoda_entity_seq; +drop table t_mapsuper1; +drop sequence t_mapsuper1_seq; +drop table t_oneb; +drop sequence t_oneb_seq; +drop table t_detail_with_other_namexxxyy; +drop sequence t_atable_detail_seq; +drop table ts_detail_two; +drop sequence ts_detail_two_seq; +drop table t_atable_thatisrelatively; +drop sequence t_atable_master_seq; +drop table ts_master_two; +drop sequence ts_master_two_seq; +drop table tuuid_entity; + +drop table twheel; +drop sequence twheel_seq; +drop table twith_pre_insert; +drop sequence twith_pre_insert_seq; +drop table mt_tenant; + +drop table sa_tire; +drop sequence sa_tire_seq; +drop table tire; +drop sequence tire_seq; +drop table trip; +drop sequence trip_seq; drop table truck_ref; +drop sequence truck_ref_seq; +drop table type; +drop sequence type_seq; +drop table ut_detail; +drop sequence ut_detail_seq; +drop table ut_master; +drop sequence ut_master_seq; +drop table uuone; +drop table uutwo; + +drop table em_user; +drop sequence em_user_seq; +drop table tx_user; +drop sequence tx_user_seq; +drop table c_user; +drop sequence c_user_seq; +drop table oto_user; +drop sequence oto_user_seq; +drop table em_user_role; +drop sequence em_user_role_seq; drop table vehicle; +drop sequence vehicle_seq; +drop table vehicle_driver; +drop sequence vehicle_driver_seq; +drop table warehouses; +drop sequence warehouses_seq; +drop table WarehousesShippingZones; +drop table sa_wheel; +drop sequence sa_wheel_seq; +drop table sp_car_wheel; +drop sequence sp_car_wheel_seq; +drop table wheel; +drop sequence wheel_seq; +drop table with_zero; +drop sequence with_zero_seq; +drop table parent; +drop sequence parent_seq; +drop table wview; + +drop table zones; +drop sequence zones_seq;