mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 14:40:46 +00:00
NEU: Db2 Tablespaces (#59)
* first commit * second commit, it works for db2 * create table index in TS * IndexTS & runPlacholdersMap * Zwischencommit * Implemented Tablespaces * Update PR * Zwischencommit * release.md * add lobTablespace support * ebean-annotation 7.7 * create index in TS ausgebaut * Fix Mergekonflikte * Migrationsskripte neu generiert * Revert "Migrationsskripte neu generiert" This reverts commit 2690718b92701c0f34661d309c129b97e3cbe053. * Revert "Fix Mergekonflikte" This reverts commit e073e25048af88205259fd6b0873c4227b27d205. * revert merge commit * Resolved merge commits * FIX: More merge conflicts and compile errors * FIX: platform.base problem * tableName uppercase * Reviewkommentare Teil 1 * Reviewkommentare Teil 2 * DbMigrationTest für DB2 gefixt * revert whitespaces * Review * review Co-authored-by: Roland Praml <roland.praml@foconis.de>
This commit is contained in:
1 parent
09230924f7
commit
4fe6f0cb13
41 files changed
+996
-42
No files matched your search
+1
-1
@@ -49,7 +49,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-annotation</artifactId>
|
<artifactId>ebean-annotation</artifactId>
|
||||||
<version>7.6</version>
|
<version>7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
|||||||
private final boolean softDelete;
|
private final boolean softDelete;
|
||||||
private final String draftTable;
|
private final String draftTable;
|
||||||
private final PartitionMeta partitionMeta;
|
private final PartitionMeta partitionMeta;
|
||||||
|
private final TablespaceMeta tablespaceMeta;
|
||||||
private final String storageEngine;
|
private final String storageEngine;
|
||||||
private final String dbComment;
|
private final String dbComment;
|
||||||
private final boolean readAuditing;
|
private final boolean readAuditing;
|
||||||
@@ -275,6 +276,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
|||||||
this.dependentTables = deploy.getDependentTables();
|
this.dependentTables = deploy.getDependentTables();
|
||||||
this.dbComment = deploy.getDbComment();
|
this.dbComment = deploy.getDbComment();
|
||||||
this.partitionMeta = deploy.getPartitionMeta();
|
this.partitionMeta = deploy.getPartitionMeta();
|
||||||
|
this.tablespaceMeta = deploy.getTablespaceMeta();
|
||||||
this.storageEngine = deploy.getStorageEngine();
|
this.storageEngine = deploy.getStorageEngine();
|
||||||
this.autoTunable = beanFinder == null && (entityType == EntityType.ORM || entityType == EntityType.VIEW);
|
this.autoTunable = beanFinder == null && (entityType == EntityType.ORM || entityType == EntityType.VIEW);
|
||||||
// helper object used to derive lists of properties
|
// helper object used to derive lists of properties
|
||||||
@@ -2671,6 +2673,13 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
|||||||
public PartitionMeta partitionMeta() {
|
public PartitionMeta partitionMeta() {
|
||||||
return partitionMeta;
|
return partitionMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the tablespace details of the bean.
|
||||||
|
*/
|
||||||
|
public TablespaceMeta tablespaceMeta() {
|
||||||
|
return tablespaceMeta;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the storage engine.
|
* Return the storage engine.
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package io.ebeaninternal.server.deploy;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Meta data for table spaces.
|
||||||
|
* If table space is configured, tablespaceName, indexTablespace, lobTablespace is never null;
|
||||||
|
*
|
||||||
|
* @author Noemi Szemenyei, FOCONIS AG
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class TablespaceMeta {
|
||||||
|
|
||||||
|
private final String tablespaceName;
|
||||||
|
private final String indexTablespace;
|
||||||
|
private final String lobTablespace;
|
||||||
|
|
||||||
|
|
||||||
|
public TablespaceMeta(String tablespaceName, String indexTablespace, String lobTablespace) {
|
||||||
|
this.tablespaceName = tablespaceName;
|
||||||
|
this.indexTablespace = indexTablespace;
|
||||||
|
this.lobTablespace = lobTablespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTablespaceName() {
|
||||||
|
return tablespaceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIndexTablespace() {
|
||||||
|
return indexTablespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLobTablespace() {
|
||||||
|
return lobTablespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(indexTablespace, tablespaceName, lobTablespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
TablespaceMeta other = (TablespaceMeta) obj;
|
||||||
|
return Objects.equals(indexTablespace, other.indexTablespace)
|
||||||
|
&& Objects.equals(tablespaceName, other.tablespaceName)
|
||||||
|
&& Objects.equals(lobTablespace, other.lobTablespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "tablespace=" + tablespaceName + ", indexTablespace=" + indexTablespace + ", lobTablespace=" + lobTablespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+10
@@ -35,6 +35,7 @@ import io.ebeaninternal.server.deploy.IndexDefinition;
|
|||||||
import io.ebeaninternal.server.deploy.InheritInfo;
|
import io.ebeaninternal.server.deploy.InheritInfo;
|
||||||
import io.ebeaninternal.server.deploy.PartitionMeta;
|
import io.ebeaninternal.server.deploy.PartitionMeta;
|
||||||
import io.ebeaninternal.server.deploy.TableJoin;
|
import io.ebeaninternal.server.deploy.TableJoin;
|
||||||
|
import io.ebeaninternal.server.deploy.TablespaceMeta;
|
||||||
import io.ebeaninternal.server.deploy.parse.DeployBeanInfo;
|
import io.ebeaninternal.server.deploy.parse.DeployBeanInfo;
|
||||||
import io.ebeaninternal.server.idgen.UuidV1IdGenerator;
|
import io.ebeaninternal.server.idgen.UuidV1IdGenerator;
|
||||||
import io.ebeaninternal.server.idgen.UuidV1RndIdGenerator;
|
import io.ebeaninternal.server.idgen.UuidV1RndIdGenerator;
|
||||||
@@ -140,6 +141,7 @@ public class DeployBeanDescriptor<T> implements DeployBeanDescriptorMeta {
|
|||||||
private ChangeLogFilter changeLogFilter;
|
private ChangeLogFilter changeLogFilter;
|
||||||
private String dbComment;
|
private String dbComment;
|
||||||
private PartitionMeta partitionMeta;
|
private PartitionMeta partitionMeta;
|
||||||
|
private TablespaceMeta tablespaceMeta;
|
||||||
/**
|
/**
|
||||||
* One of NONE, INDEX or EMBEDDED.
|
* One of NONE, INDEX or EMBEDDED.
|
||||||
*/
|
*/
|
||||||
@@ -261,6 +263,14 @@ public class DeployBeanDescriptor<T> implements DeployBeanDescriptorMeta {
|
|||||||
}
|
}
|
||||||
return partitionMeta;
|
return partitionMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTablespaceMeta(TablespaceMeta tablespaceMeta) {
|
||||||
|
this.tablespaceMeta = tablespaceMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TablespaceMeta getTablespaceMeta() {
|
||||||
|
return tablespaceMeta;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDraftable() {
|
public void setDraftable() {
|
||||||
draftable = true;
|
draftable = true;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import io.ebean.annotation.Index;
|
|||||||
import io.ebean.annotation.InvalidateQueryCache;
|
import io.ebean.annotation.InvalidateQueryCache;
|
||||||
import io.ebean.annotation.ReadAudit;
|
import io.ebean.annotation.ReadAudit;
|
||||||
import io.ebean.annotation.StorageEngine;
|
import io.ebean.annotation.StorageEngine;
|
||||||
|
import io.ebean.annotation.Tablespace;
|
||||||
import io.ebean.annotation.View;
|
import io.ebean.annotation.View;
|
||||||
import io.ebean.config.TableName;
|
import io.ebean.config.TableName;
|
||||||
import io.ebean.util.AnnotationUtil;
|
import io.ebean.util.AnnotationUtil;
|
||||||
@@ -22,6 +23,7 @@ import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
|
|||||||
import io.ebeaninternal.server.deploy.IndexDefinition;
|
import io.ebeaninternal.server.deploy.IndexDefinition;
|
||||||
import io.ebeaninternal.server.deploy.InheritInfo;
|
import io.ebeaninternal.server.deploy.InheritInfo;
|
||||||
import io.ebeaninternal.server.deploy.PartitionMeta;
|
import io.ebeaninternal.server.deploy.PartitionMeta;
|
||||||
|
import io.ebeaninternal.server.deploy.TablespaceMeta;
|
||||||
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
|
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
|
||||||
|
|
||||||
import javax.persistence.AttributeOverride;
|
import javax.persistence.AttributeOverride;
|
||||||
@@ -158,6 +160,18 @@ final class AnnotationClass extends AnnotationParser {
|
|||||||
if (partition != null) {
|
if (partition != null) {
|
||||||
descriptor.setPartitionMeta(new PartitionMeta(partition.mode(), partition.property()));
|
descriptor.setPartitionMeta(new PartitionMeta(partition.mode(), partition.property()));
|
||||||
}
|
}
|
||||||
|
Tablespace tablespace = typeGet(cls, Tablespace.class);
|
||||||
|
if (tablespace != null) {
|
||||||
|
String indexTs = tablespace.index();
|
||||||
|
if("".equals(indexTs)) {
|
||||||
|
indexTs = tablespace.value();
|
||||||
|
}
|
||||||
|
String lobTs = tablespace.lob();
|
||||||
|
if("".equals(lobTs)) {
|
||||||
|
lobTs = tablespace.value();
|
||||||
|
}
|
||||||
|
descriptor.setTablespaceMeta(new TablespaceMeta(tablespace.value(), indexTs, lobTs));
|
||||||
|
}
|
||||||
Draftable draftable = typeGet(cls, Draftable.class);
|
Draftable draftable = typeGet(cls, Draftable.class);
|
||||||
if (draftable != null) {
|
if (draftable != null) {
|
||||||
descriptor.setDraftable();
|
descriptor.setDraftable();
|
||||||
|
|||||||
+8
@@ -9,6 +9,7 @@ import io.ebeaninternal.dbmigration.migration.AddTableComment;
|
|||||||
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
||||||
|
import io.ebeaninternal.dbmigration.migration.AlterTable;
|
||||||
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
||||||
@@ -49,6 +50,8 @@ public class BaseDdlHandler implements DdlHandler {
|
|||||||
// ignore
|
// ignore
|
||||||
} else if (change instanceof DropTable) {
|
} else if (change instanceof DropTable) {
|
||||||
generate(writer, (DropTable) change);
|
generate(writer, (DropTable) change);
|
||||||
|
} else if (change instanceof AlterTable) {
|
||||||
|
generate(writer, (AlterTable) change);
|
||||||
} else if (change instanceof AddTableComment) {
|
} else if (change instanceof AddTableComment) {
|
||||||
generate(writer, (AddTableComment) change);
|
generate(writer, (AddTableComment) change);
|
||||||
} else if (change instanceof CreateIndex) {
|
} else if (change instanceof CreateIndex) {
|
||||||
@@ -94,6 +97,11 @@ public class BaseDdlHandler implements DdlHandler {
|
|||||||
public void generate(DdlWrite writer, DropTable dropTable) throws IOException {
|
public void generate(DdlWrite writer, DropTable dropTable) throws IOException {
|
||||||
tableDdl.generate(writer, dropTable);
|
tableDdl.generate(writer, dropTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(DdlWrite writer, AlterTable alterTable) throws IOException {
|
||||||
|
tableDdl.generate(writer, alterTable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate(DdlWrite writer, AddTableComment addTableComment) throws IOException {
|
public void generate(DdlWrite writer, AddTableComment addTableComment) throws IOException {
|
||||||
|
|||||||
+3
@@ -6,6 +6,7 @@ import io.ebeaninternal.dbmigration.migration.AddTableComment;
|
|||||||
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
||||||
|
import io.ebeaninternal.dbmigration.migration.AlterTable;
|
||||||
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
||||||
@@ -26,6 +27,8 @@ public interface DdlHandler {
|
|||||||
void generate(DdlWrite writer, CreateTable createTable) throws IOException;
|
void generate(DdlWrite writer, CreateTable createTable) throws IOException;
|
||||||
|
|
||||||
void generate(DdlWrite writer, DropTable dropTable) throws IOException;
|
void generate(DdlWrite writer, DropTable dropTable) throws IOException;
|
||||||
|
|
||||||
|
void generate(DdlWrite writer, AlterTable dropTable) throws IOException;
|
||||||
|
|
||||||
void generate(DdlWrite writer, AddTableComment addTableComment) throws IOException;
|
void generate(DdlWrite writer, AddTableComment addTableComment) throws IOException;
|
||||||
|
|
||||||
|
|||||||
+6
@@ -6,6 +6,7 @@ import io.ebeaninternal.dbmigration.migration.AddTableComment;
|
|||||||
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
||||||
|
import io.ebeaninternal.dbmigration.migration.AlterTable;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
||||||
import io.ebeaninternal.dbmigration.migration.DropColumn;
|
import io.ebeaninternal.dbmigration.migration.DropColumn;
|
||||||
@@ -29,6 +30,11 @@ public interface TableDdl {
|
|||||||
* Write the drop column change.
|
* Write the drop column change.
|
||||||
*/
|
*/
|
||||||
void generate(DdlWrite writer, DropTable dropTable) throws IOException;
|
void generate(DdlWrite writer, DropTable dropTable) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write alter table changes.
|
||||||
|
*/
|
||||||
|
void generate(DdlWrite writer, AlterTable dropTable) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the add column change.
|
* Write the add column change.
|
||||||
|
|||||||
+28
-3
@@ -18,6 +18,7 @@ import io.ebeaninternal.dbmigration.migration.AddTableComment;
|
|||||||
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
||||||
|
import io.ebeaninternal.dbmigration.migration.AlterTable;
|
||||||
import io.ebeaninternal.dbmigration.migration.Column;
|
import io.ebeaninternal.dbmigration.migration.Column;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
||||||
@@ -198,7 +199,7 @@ public class BaseTableDdl implements TableDdl {
|
|||||||
|
|
||||||
private void handleStrictError(String tableName, String columnName) {
|
private void handleStrictError(String tableName, String columnName) {
|
||||||
if (strictMode) {
|
if (strictMode) {
|
||||||
String message = "DB Migration of non-null column with no default value specified for: " + tableName + "." + columnName+" Use @DbDefault to specify a default value or specify dbMigration.setStrictMode(false)";
|
String message = "DB Migration of non-null column with no default value specified for: " + tableName + "." + columnName+" Use @DbDefault to specify a default value or disable strict mode for migration";
|
||||||
throw new IllegalArgumentException(message);
|
throw new IllegalArgumentException(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,6 +280,10 @@ public class BaseTableDdl implements TableDdl {
|
|||||||
writeInlineForeignKeys(writer, createTable);
|
writeInlineForeignKeys(writer, createTable);
|
||||||
}
|
}
|
||||||
apply.newLine().append(")");
|
apply.newLine().append(")");
|
||||||
|
if (createTable.getTablespace() != null) {
|
||||||
|
platformDdl.addTablespace(apply, createTable.getTablespace(), createTable.getIndexTablespace(),
|
||||||
|
createTable.getLobTablespace());
|
||||||
|
}
|
||||||
addTableStorageEngine(apply, createTable);
|
addTableStorageEngine(apply, createTable);
|
||||||
addTableCommentInline(apply, createTable);
|
addTableCommentInline(apply, createTable);
|
||||||
if (partitionMode != null) {
|
if (partitionMode != null) {
|
||||||
@@ -582,12 +587,12 @@ public class BaseTableDdl implements TableDdl {
|
|||||||
}
|
}
|
||||||
return pk;
|
return pk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate(DdlWrite writer, CreateIndex index) throws IOException {
|
public void generate(DdlWrite writer, CreateIndex index) throws IOException {
|
||||||
if (platformInclude(index.getPlatforms())) {
|
if (platformInclude(index.getPlatforms())) {
|
||||||
flushReorgTables(writer.apply());
|
flushReorgTables(writer.apply());
|
||||||
writer.apply().appendStatement(platformDdl.createIndex(new WriteCreateIndex(index)));
|
writer.apply().appendStatement(platformDdl.createIndex(new WriteCreateIndex(index)));
|
||||||
writer.dropAll().appendStatement(platformDdl.dropIndex(index.getIndexName(), index.getTableName(), Boolean.TRUE.equals(index.isConcurrent())));
|
writer.dropAll().appendStatement(platformDdl.dropIndex(index.getIndexName(), index.getTableName(), Boolean.TRUE.equals(index.isConcurrent())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -712,6 +717,26 @@ public class BaseTableDdl implements TableDdl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(DdlWrite writer, AlterTable alterTable) throws IOException {
|
||||||
|
if (hasValue(alterTable.getTablespace()) || hasValue(alterTable.getIndexTablespace()) || hasValue(alterTable.getLobTablespace())) {
|
||||||
|
writer.apply().appendStatement(platformDdl.alterTableTablespace(alterTable.getName(),
|
||||||
|
DdlHelp.toTablespace(alterTable.getTablespace()),
|
||||||
|
DdlHelp.toTablespace(alterTable.getIndexTablespace()),
|
||||||
|
DdlHelp.toTablespace(alterTable.getLobTablespace())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeTablespaceChange(DdlBuffer buffer, String tablename, String tableSpace, String indexSpace,
|
||||||
|
String lobSpace) throws IOException {
|
||||||
|
buffer.appendStatement("-- TableSpace changed: Table: " + tablename + ", tableSpace " + tableSpace + ", indexSpace "
|
||||||
|
+ indexSpace + ", lobSpace " + lobSpace);
|
||||||
|
if (strictMode) {
|
||||||
|
throw new UnsupportedOperationException(
|
||||||
|
"Tablespace change is not supported by this platform. Disable strict mode for migration and write migration manually");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add drop column DDL.
|
* Add drop column DDL.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+22
-3
@@ -1,7 +1,10 @@
|
|||||||
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import io.ebean.annotation.ConstraintMode;
|
import io.ebean.annotation.ConstraintMode;
|
||||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||||
|
import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DB2 platform specific DDL.
|
* DB2 platform specific DDL.
|
||||||
@@ -29,7 +32,8 @@ import io.ebean.config.dbplatform.DatabasePlatform;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DB2Ddl extends PlatformDdl {
|
public class DB2Ddl extends PlatformDdl {
|
||||||
|
private static final String MOVE_TABLE = "CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'%s','%s','%s','%s','','','','','','MOVE')";
|
||||||
|
|
||||||
public DB2Ddl(DatabasePlatform platform) {
|
public DB2Ddl(DatabasePlatform platform) {
|
||||||
super(platform);
|
super(platform);
|
||||||
this.dropTableIfExists = "drop table ";
|
this.dropTableIfExists = "drop table ";
|
||||||
@@ -42,6 +46,16 @@ public class DB2Ddl extends PlatformDdl {
|
|||||||
this.inlineUniqueWhenNullable = false;
|
this.inlineUniqueWhenNullable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String alterTableTablespace(String tablename, String tableSpace, String indexSpace, String lobSpace) {
|
||||||
|
if(tableSpace == null) {
|
||||||
|
// if no tableSpace set, use the default tablespace USERSPACE1
|
||||||
|
return String.format(MOVE_TABLE, tablename.toUpperCase(), "USERSPACE1", "USERSPACE1", "USERSPACE1");
|
||||||
|
} else {
|
||||||
|
return String.format(MOVE_TABLE, tablename.toUpperCase(), tableSpace, indexSpace, lobSpace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns,
|
public String alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns,
|
||||||
String[] nullableColumns) {
|
String[] nullableColumns) {
|
||||||
@@ -135,8 +149,13 @@ public class DB2Ddl extends PlatformDdl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String reorgTable(String table, int counter) {
|
public String reorgTable(String table, int counter) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return "call sysproc.admin_cmd('reorg table " + lowerTableName(table) + "') /* reorg #" + counter + " */";
|
return "call sysproc.admin_cmd('reorg table " + lowerTableName(table) + "') /* reorg #" + counter + " */";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTablespace(DdlBuffer apply, String tablespaceName, String indexTablespace, String lobTablespace)
|
||||||
|
throws IOException {
|
||||||
|
apply.append(" in ").append(tablespaceName).append(" index in ").append(indexTablespace).append(" long in ").append(lobTablespace);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+13
@@ -1,6 +1,8 @@
|
|||||||
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||||
|
|
||||||
public class DdlHelp {
|
public class DdlHelp {
|
||||||
|
public static final String TABLESPACE_DEFAULT = "$TABLESPACE_DEFAULT";
|
||||||
|
|
||||||
public static final String DROP_DEFAULT = "DROP DEFAULT";
|
public static final String DROP_DEFAULT = "DROP DEFAULT";
|
||||||
|
|
||||||
public static final String DROP_COMMENT = "DROP COMMENT";
|
public static final String DROP_COMMENT = "DROP COMMENT";
|
||||||
@@ -36,4 +38,15 @@ public class DdlHelp {
|
|||||||
public static boolean isDropForeignKey(String value) {
|
public static boolean isDropForeignKey(String value) {
|
||||||
return DROP_FOREIGN_KEY.equals(value);
|
return DROP_FOREIGN_KEY.equals(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tablespace. Returns null, if this is the special '$TABLESPACE_DEFAULT' value.
|
||||||
|
*/
|
||||||
|
public static String toTablespace(String tablespace) {
|
||||||
|
if (TABLESPACE_DEFAULT.equals(tablespace)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return tablespace;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+17
-2
@@ -127,7 +127,7 @@ public class PlatformDdl {
|
|||||||
protected boolean inlineForeignKeys;
|
protected boolean inlineForeignKeys;
|
||||||
|
|
||||||
protected boolean includeStorageEngine;
|
protected boolean includeStorageEngine;
|
||||||
|
|
||||||
protected final DbDefaultValue dbDefaultValue;
|
protected final DbDefaultValue dbDefaultValue;
|
||||||
|
|
||||||
protected String fallbackArrayType = "varchar(1000)";
|
protected String fallbackArrayType = "varchar(1000)";
|
||||||
@@ -400,7 +400,7 @@ public class PlatformDdl {
|
|||||||
public String dropIndex(String indexName, String tableName, boolean concurrent) {
|
public String dropIndex(String indexName, String tableName, boolean concurrent) {
|
||||||
return dropIndexIfExists + maxConstraintName(indexName);
|
return dropIndexIfExists + maxConstraintName(indexName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createIndex(WriteCreateIndex create) {
|
public String createIndex(WriteCreateIndex create) {
|
||||||
if (create.useDefinition()) {
|
if (create.useDefinition()) {
|
||||||
return create.getDefinition();
|
return create.getDefinition();
|
||||||
@@ -508,6 +508,13 @@ public class PlatformDdl {
|
|||||||
return "alter table " + tableName + " " + dropConstraintIfExists + " " + maxConstraintName(constraintName);
|
return "alter table " + tableName + " " + dropConstraintIfExists + " " + maxConstraintName(constraintName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the table to an other tablespace.
|
||||||
|
*/
|
||||||
|
public String alterTableTablespace(String tablename, String tableSpace, String indexSpace, String lobSpace) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a unique constraint to the table.
|
* Add a unique constraint to the table.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -772,6 +779,14 @@ public class PlatformDdl {
|
|||||||
public void addTablePartition(DdlBuffer apply, String partitionMode, String partitionColumn) throws IOException {
|
public void addTablePartition(DdlBuffer apply, String partitionMode, String partitionColumn) throws IOException {
|
||||||
// only supported by postgres initially
|
// only supported by postgres initially
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds tablespace declaration. Now only supported for db2.
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void addTablespace(DdlBuffer apply, String tablespaceName, String indexTablespace, String lobTablespace) throws IOException{
|
||||||
|
// now only supported for db2
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a statement to reorganize the table. This is required mainly for DB2.
|
* Returns a statement to reorganize the table. This is required mainly for DB2.
|
||||||
|
|||||||
+526
@@ -0,0 +1,526 @@
|
|||||||
|
//
|
||||||
|
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
|
||||||
|
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||||
|
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||||
|
// Generated on: 2022.02.01 at 12:03:38 PM CET
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
package io.ebeaninternal.dbmigration.migration;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
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.XmlSchemaType;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Java class for anonymous complex type.
|
||||||
|
*
|
||||||
|
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType>
|
||||||
|
* <complexContent>
|
||||||
|
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||||
|
* <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="newName" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||||
|
* <attribute name="partitionMode" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||||
|
* <attribute name="partitionColumn" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||||
|
* <attribute name="identityType" type="{http://ebean-orm.github.io/xml/ns/dbmigration}identityType" />
|
||||||
|
* <attribute name="identityStart" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
|
||||||
|
* <attribute name="identityIncrement" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
|
||||||
|
* <attribute name="identityCache" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
|
||||||
|
* <attribute name="identityGenerated" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||||
|
* <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" />
|
||||||
|
* <attribute name="pkName" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||||
|
* <attribute name="storageEngine" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||||
|
* </restriction>
|
||||||
|
* </complexContent>
|
||||||
|
* </complexType>
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "")
|
||||||
|
@XmlRootElement(name = "alterTable")
|
||||||
|
public class AlterTable {
|
||||||
|
|
||||||
|
@XmlAttribute(name = "name", required = true)
|
||||||
|
protected String name;
|
||||||
|
@XmlAttribute(name = "newName")
|
||||||
|
protected String newName;
|
||||||
|
@XmlAttribute(name = "partitionMode")
|
||||||
|
protected String partitionMode;
|
||||||
|
@XmlAttribute(name = "partitionColumn")
|
||||||
|
protected String partitionColumn;
|
||||||
|
@XmlAttribute(name = "identityType")
|
||||||
|
protected IdentityType identityType;
|
||||||
|
@XmlAttribute(name = "identityStart")
|
||||||
|
@XmlSchemaType(name = "positiveInteger")
|
||||||
|
protected BigInteger identityStart;
|
||||||
|
@XmlAttribute(name = "identityIncrement")
|
||||||
|
@XmlSchemaType(name = "positiveInteger")
|
||||||
|
protected BigInteger identityIncrement;
|
||||||
|
@XmlAttribute(name = "identityCache")
|
||||||
|
@XmlSchemaType(name = "positiveInteger")
|
||||||
|
protected BigInteger identityCache;
|
||||||
|
@XmlAttribute(name = "identityGenerated")
|
||||||
|
protected String identityGenerated;
|
||||||
|
@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 = "pkName")
|
||||||
|
protected String pkName;
|
||||||
|
@XmlAttribute(name = "storageEngine")
|
||||||
|
protected String storageEngine;
|
||||||
|
@XmlAttribute(name = "tablespace")
|
||||||
|
protected String tablespace;
|
||||||
|
@XmlAttribute(name = "indexTablespace")
|
||||||
|
protected String indexTablespace;
|
||||||
|
@XmlAttribute(name = "lobTablespace")
|
||||||
|
protected String lobTablespace;
|
||||||
|
@XmlAttribute(name = "comment")
|
||||||
|
protected String comment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the name property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the name property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setName(String value) {
|
||||||
|
this.name = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the newName property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getNewName() {
|
||||||
|
return newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the newName property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setNewName(String value) {
|
||||||
|
this.newName = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the partitionMode property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getPartitionMode() {
|
||||||
|
return partitionMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the partitionMode property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setPartitionMode(String value) {
|
||||||
|
this.partitionMode = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the partitionColumn property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getPartitionColumn() {
|
||||||
|
return partitionColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the partitionColumn property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setPartitionColumn(String value) {
|
||||||
|
this.partitionColumn = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the identityType property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link IdentityType }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public IdentityType getIdentityType() {
|
||||||
|
return identityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the identityType property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link IdentityType }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setIdentityType(IdentityType value) {
|
||||||
|
this.identityType = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the identityStart property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link BigInteger }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public BigInteger getIdentityStart() {
|
||||||
|
return identityStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the identityStart property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link BigInteger }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setIdentityStart(BigInteger value) {
|
||||||
|
this.identityStart = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the identityIncrement property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link BigInteger }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public BigInteger getIdentityIncrement() {
|
||||||
|
return identityIncrement;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the identityIncrement property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link BigInteger }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setIdentityIncrement(BigInteger value) {
|
||||||
|
this.identityIncrement = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the identityCache property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link BigInteger }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public BigInteger getIdentityCache() {
|
||||||
|
return identityCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the identityCache property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link BigInteger }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setIdentityCache(BigInteger value) {
|
||||||
|
this.identityCache = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the identityGenerated property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getIdentityGenerated() {
|
||||||
|
return identityGenerated;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the identityGenerated property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setIdentityGenerated(String value) {
|
||||||
|
this.identityGenerated = 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 pkName property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getPkName() {
|
||||||
|
return pkName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the pkName property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setPkName(String value) {
|
||||||
|
this.pkName = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the storageEngine property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getStorageEngine() {
|
||||||
|
return storageEngine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the storageEngine property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setStorageEngine(String value) {
|
||||||
|
this.storageEngine = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the tablespace property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getTablespace() {
|
||||||
|
return tablespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the tablespace property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setTablespace(String value) {
|
||||||
|
this.tablespace = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the indexTablespace property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getIndexTablespace() {
|
||||||
|
return indexTablespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the indexTablespace property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setIndexTablespace(String value) {
|
||||||
|
this.indexTablespace = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the lobTablespace property.
|
||||||
|
*
|
||||||
|
* @return possible object is
|
||||||
|
* {@link String }
|
||||||
|
*/
|
||||||
|
public String getLobTablespace() {
|
||||||
|
return lobTablespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the lobTablespace property.
|
||||||
|
*
|
||||||
|
* @param value allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*/
|
||||||
|
public void setLobTablespace(String value) {
|
||||||
|
this.lobTablespace = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the comment property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the comment property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setComment(String value) {
|
||||||
|
this.comment = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
@@ -47,6 +47,7 @@ public class ChangeSet {
|
|||||||
@XmlElement(name = "configuration", type = Configuration.class),
|
@XmlElement(name = "configuration", type = Configuration.class),
|
||||||
@XmlElement(name = "sql", type = Sql.class),
|
@XmlElement(name = "sql", type = Sql.class),
|
||||||
@XmlElement(name = "createTable", type = CreateTable.class),
|
@XmlElement(name = "createTable", type = CreateTable.class),
|
||||||
|
@XmlElement(name = "alterTable", type = AlterTable.class),
|
||||||
@XmlElement(name = "dropTable", type = DropTable.class),
|
@XmlElement(name = "dropTable", type = DropTable.class),
|
||||||
@XmlElement(name = "renameTable", type = RenameTable.class),
|
@XmlElement(name = "renameTable", type = RenameTable.class),
|
||||||
@XmlElement(name = "addTableComment", type = AddTableComment.class),
|
@XmlElement(name = "addTableComment", type = AddTableComment.class),
|
||||||
|
|||||||
+22
@@ -99,6 +99,8 @@ public class CreateTable {
|
|||||||
protected String tablespace;
|
protected String tablespace;
|
||||||
@XmlAttribute(name = "indexTablespace")
|
@XmlAttribute(name = "indexTablespace")
|
||||||
protected String indexTablespace;
|
protected String indexTablespace;
|
||||||
|
@XmlAttribute(name = "lobTablespace")
|
||||||
|
protected String lobTablespace;
|
||||||
@XmlAttribute(name = "comment")
|
@XmlAttribute(name = "comment")
|
||||||
protected String comment;
|
protected String comment;
|
||||||
|
|
||||||
@@ -522,6 +524,26 @@ public class CreateTable {
|
|||||||
public void setIndexTablespace(String value) {
|
public void setIndexTablespace(String value) {
|
||||||
this.indexTablespace = value;
|
this.indexTablespace = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the lobTablespace property.
|
||||||
|
*
|
||||||
|
* @return possible object is
|
||||||
|
* {@link String }
|
||||||
|
*/
|
||||||
|
public String getLobTablespace() {
|
||||||
|
return lobTablespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the lobTablespace property.
|
||||||
|
*
|
||||||
|
* @param value allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*/
|
||||||
|
public void setLobTablespace(String value) {
|
||||||
|
this.lobTablespace = value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the comment property.
|
* Gets the value of the comment property.
|
||||||
|
|||||||
+8
@@ -187,6 +187,14 @@ public class ObjectFactory {
|
|||||||
return new ChangeSet();
|
return new ChangeSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link AlterTable }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public AlterTable createAlterTable() {
|
||||||
|
return new AlterTable();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of {@link AddHistoryTable }
|
* Create an instance of {@link AddHistoryTable }
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.ebeaninternal.dbmigration.migration.AddColumn;
|
|||||||
import io.ebeaninternal.dbmigration.migration.AddHistoryTable;
|
import io.ebeaninternal.dbmigration.migration.AddHistoryTable;
|
||||||
import io.ebeaninternal.dbmigration.migration.AddTableComment;
|
import io.ebeaninternal.dbmigration.migration.AddTableComment;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
||||||
|
import io.ebeaninternal.dbmigration.migration.AlterTable;
|
||||||
import io.ebeaninternal.dbmigration.migration.Column;
|
import io.ebeaninternal.dbmigration.migration.Column;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
||||||
import io.ebeaninternal.dbmigration.migration.DropColumn;
|
import io.ebeaninternal.dbmigration.migration.DropColumn;
|
||||||
@@ -17,6 +18,8 @@ import io.ebeaninternal.server.deploy.BeanDescriptor;
|
|||||||
import io.ebeaninternal.server.deploy.BeanProperty;
|
import io.ebeaninternal.server.deploy.BeanProperty;
|
||||||
import io.ebeaninternal.server.deploy.IdentityMode;
|
import io.ebeaninternal.server.deploy.IdentityMode;
|
||||||
import io.ebeaninternal.server.deploy.PartitionMeta;
|
import io.ebeaninternal.server.deploy.PartitionMeta;
|
||||||
|
import io.ebeaninternal.server.deploy.TablespaceMeta;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -26,6 +29,7 @@ import java.util.HashSet;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static io.ebeaninternal.dbmigration.ddlgeneration.platform.SplitColumns.split;
|
import static io.ebeaninternal.dbmigration.ddlgeneration.platform.SplitColumns.split;
|
||||||
@@ -56,11 +60,10 @@ public class MTable {
|
|||||||
*/
|
*/
|
||||||
private boolean draft;
|
private boolean draft;
|
||||||
private PartitionMeta partitionMeta;
|
private PartitionMeta partitionMeta;
|
||||||
|
private TablespaceMeta tablespaceMeta;
|
||||||
private String pkName;
|
private String pkName;
|
||||||
private String comment;
|
private String comment;
|
||||||
private String tablespace;
|
|
||||||
private String storageEngine;
|
private String storageEngine;
|
||||||
private String indexTablespace;
|
|
||||||
private IdentityMode identityMode;
|
private IdentityMode identityMode;
|
||||||
private boolean withHistory;
|
private boolean withHistory;
|
||||||
private final Map<String, MColumn> columns = new LinkedHashMap<>();
|
private final Map<String, MColumn> columns = new LinkedHashMap<>();
|
||||||
@@ -93,6 +96,7 @@ public class MTable {
|
|||||||
this.identityMode = descriptor.identityMode();
|
this.identityMode = descriptor.identityMode();
|
||||||
this.storageEngine = descriptor.storageEngine();
|
this.storageEngine = descriptor.storageEngine();
|
||||||
this.partitionMeta = descriptor.partitionMeta();
|
this.partitionMeta = descriptor.partitionMeta();
|
||||||
|
this.tablespaceMeta = descriptor.tablespaceMeta();
|
||||||
this.comment = descriptor.dbComment();
|
this.comment = descriptor.dbComment();
|
||||||
if (descriptor.isHistorySupport()) {
|
if (descriptor.isHistorySupport()) {
|
||||||
withHistory = true;
|
withHistory = true;
|
||||||
@@ -104,11 +108,28 @@ public class MTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct for element collection or intersection table.
|
* Constructor for test cases only!
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public MTable(String name) {
|
public MTable(String name) {
|
||||||
|
this(name, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct for element collection or intersection table. They have same table space and storage engine.
|
||||||
|
*/
|
||||||
|
public MTable(String name, BeanDescriptor<?> descriptor) {
|
||||||
|
this(name, descriptor.tablespaceMeta(), descriptor.storageEngine());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for dependant tables (draft/element collection or intersection).
|
||||||
|
*/
|
||||||
|
private MTable(String name, TablespaceMeta tablespaceMeta, String storageEngine) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.identityMode = IdentityMode.NONE;
|
this.identityMode = IdentityMode.NONE;
|
||||||
|
this.tablespaceMeta = tablespaceMeta;
|
||||||
|
this.storageEngine = storageEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,7 +139,7 @@ public class MTable {
|
|||||||
* later when creating the CreateTable object.
|
* later when creating the CreateTable object.
|
||||||
*/
|
*/
|
||||||
public MTable createDraftTable() {
|
public MTable createDraftTable() {
|
||||||
draftTable = new MTable(name + "_draft");
|
draftTable = new MTable(name + "_draft", this.tablespaceMeta, this.storageEngine);
|
||||||
draftTable.draft = true;
|
draftTable.draft = true;
|
||||||
draftTable.whenCreatedColumn = whenCreatedColumn;
|
draftTable.whenCreatedColumn = whenCreatedColumn;
|
||||||
// compoundKeys
|
// compoundKeys
|
||||||
@@ -138,8 +159,13 @@ public class MTable {
|
|||||||
this.pkName = createTable.getPkName();
|
this.pkName = createTable.getPkName();
|
||||||
this.comment = createTable.getComment();
|
this.comment = createTable.getComment();
|
||||||
this.storageEngine = createTable.getStorageEngine();
|
this.storageEngine = createTable.getStorageEngine();
|
||||||
this.tablespace = createTable.getTablespace();
|
if (createTable.getTablespace() != null) {
|
||||||
this.indexTablespace = createTable.getIndexTablespace();
|
this.tablespaceMeta = new TablespaceMeta(createTable.getTablespace(),
|
||||||
|
createTable.getIndexTablespace() != null ? createTable.getIndexTablespace() : createTable.getTablespace(),
|
||||||
|
createTable.getLobTablespace() != null ? createTable.getLobTablespace() : createTable.getTablespace());
|
||||||
|
} else {
|
||||||
|
this.tablespaceMeta = null;
|
||||||
|
}
|
||||||
this.withHistory = Boolean.TRUE.equals(createTable.isWithHistory());
|
this.withHistory = Boolean.TRUE.equals(createTable.isWithHistory());
|
||||||
this.draft = Boolean.TRUE.equals(createTable.isDraft());
|
this.draft = Boolean.TRUE.equals(createTable.isDraft());
|
||||||
this.identityMode = fromCreateTable(createTable);
|
this.identityMode = fromCreateTable(createTable);
|
||||||
@@ -210,8 +236,11 @@ public class MTable {
|
|||||||
createTable.setPartitionColumn(partitionMeta.getProperty());
|
createTable.setPartitionColumn(partitionMeta.getProperty());
|
||||||
}
|
}
|
||||||
createTable.setStorageEngine(storageEngine);
|
createTable.setStorageEngine(storageEngine);
|
||||||
createTable.setTablespace(tablespace);
|
if (tablespaceMeta != null) {
|
||||||
createTable.setIndexTablespace(indexTablespace);
|
createTable.setTablespace(tablespaceMeta.getTablespaceName());
|
||||||
|
createTable.setIndexTablespace(tablespaceMeta.getIndexTablespace());
|
||||||
|
createTable.setLobTablespace(tablespaceMeta.getLobTablespace());
|
||||||
|
}
|
||||||
toCreateTable(identityMode, createTable);
|
toCreateTable(identityMode, createTable);
|
||||||
if (withHistory) {
|
if (withHistory) {
|
||||||
createTable.setWithHistory(Boolean.TRUE);
|
createTable.setWithHistory(Boolean.TRUE);
|
||||||
@@ -266,6 +295,8 @@ public class MTable {
|
|||||||
|
|
||||||
compareCompoundKeys(modelDiff, newTable);
|
compareCompoundKeys(modelDiff, newTable);
|
||||||
compareUniqueKeys(modelDiff, newTable);
|
compareUniqueKeys(modelDiff, newTable);
|
||||||
|
compareTableAttrs(modelDiff, newTable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void compareColumns(ModelDiff modelDiff, MTable newTable) {
|
private void compareColumns(ModelDiff modelDiff, MTable newTable) {
|
||||||
@@ -335,6 +366,29 @@ public class MTable {
|
|||||||
modelDiff.addUniqueConstraint(newKey.addUniqueConstraint(name));
|
modelDiff.addUniqueConstraint(newKey.addUniqueConstraint(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void compareTableAttrs(ModelDiff modelDiff, MTable newTable) {
|
||||||
|
AlterTable alterTable = new AlterTable();
|
||||||
|
alterTable.setName(newTable.getName());
|
||||||
|
boolean altered = false;
|
||||||
|
|
||||||
|
if (!Objects.equals(tablespaceMeta, newTable.getTablespaceMeta())) {
|
||||||
|
if (newTable.getTablespaceMeta() == null) {
|
||||||
|
alterTable.setTablespace(DdlHelp.TABLESPACE_DEFAULT);
|
||||||
|
alterTable.setIndexTablespace(DdlHelp.TABLESPACE_DEFAULT);
|
||||||
|
alterTable.setLobTablespace(DdlHelp.TABLESPACE_DEFAULT);
|
||||||
|
} else {
|
||||||
|
alterTable.setTablespace(newTable.getTablespaceMeta().getTablespaceName());
|
||||||
|
alterTable.setIndexTablespace(newTable.getTablespaceMeta().getIndexTablespace());
|
||||||
|
alterTable.setLobTablespace(newTable.getTablespaceMeta().getLobTablespace());
|
||||||
|
}
|
||||||
|
altered = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (altered) {
|
||||||
|
modelDiff.addAlterTable(alterTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply AddColumn migration.
|
* Apply AddColumn migration.
|
||||||
@@ -424,13 +478,13 @@ public class MTable {
|
|||||||
public void setComment(String comment) {
|
public void setComment(String comment) {
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTablespace() {
|
public void setTablespaceMeta(TablespaceMeta tablespaceMeta) {
|
||||||
return tablespace;
|
this.tablespaceMeta = tablespaceMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIndexTablespace() {
|
public TablespaceMeta getTablespaceMeta() {
|
||||||
return indexTablespace;
|
return tablespaceMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWithHistory() {
|
public boolean isWithHistory() {
|
||||||
|
|||||||
+30
@@ -8,6 +8,7 @@ import io.ebeaninternal.dbmigration.migration.AddTableComment;
|
|||||||
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
||||||
|
import io.ebeaninternal.dbmigration.migration.AlterTable;
|
||||||
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
||||||
import io.ebeaninternal.dbmigration.migration.ChangeSetType;
|
import io.ebeaninternal.dbmigration.migration.ChangeSetType;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
||||||
@@ -19,6 +20,7 @@ import io.ebeaninternal.dbmigration.migration.DropTable;
|
|||||||
import io.ebeaninternal.dbmigration.migration.Migration;
|
import io.ebeaninternal.dbmigration.migration.Migration;
|
||||||
import io.ebeaninternal.dbmigration.migration.RenameColumn;
|
import io.ebeaninternal.dbmigration.migration.RenameColumn;
|
||||||
import io.ebeaninternal.dbmigration.migration.Sql;
|
import io.ebeaninternal.dbmigration.migration.Sql;
|
||||||
|
import io.ebeaninternal.server.deploy.TablespaceMeta;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -155,6 +157,8 @@ public class ModelContainer {
|
|||||||
applyChange((CreateTable) change);
|
applyChange((CreateTable) change);
|
||||||
} else if (change instanceof DropTable) {
|
} else if (change instanceof DropTable) {
|
||||||
applyChange((DropTable) change);
|
applyChange((DropTable) change);
|
||||||
|
} else if (change instanceof AlterTable) {
|
||||||
|
applyChange((AlterTable) change);
|
||||||
} else if (change instanceof AlterColumn) {
|
} else if (change instanceof AlterColumn) {
|
||||||
applyChange((AlterColumn) change);
|
applyChange((AlterColumn) change);
|
||||||
} else if (change instanceof AddColumn) {
|
} else if (change instanceof AddColumn) {
|
||||||
@@ -261,6 +265,32 @@ public class ModelContainer {
|
|||||||
protected void applyChange(DropTable dropTable) {
|
protected void applyChange(DropTable dropTable) {
|
||||||
tables.remove(dropTable.getName());
|
tables.remove(dropTable.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void applyChange(AlterTable alterTable) {
|
||||||
|
MTable table = getTable(alterTable.getName());
|
||||||
|
if (table == null) {
|
||||||
|
throw new IllegalStateException("Table [" + alterTable.getName() + "] does not exist in model?");
|
||||||
|
}
|
||||||
|
// Handle Tablespace change
|
||||||
|
TablespaceMeta ts = table.getTablespaceMeta();
|
||||||
|
|
||||||
|
if (alterTable.getTablespace() != null) {
|
||||||
|
String currentTableSpace = DdlHelp.toTablespace(alterTable.getTablespace());
|
||||||
|
String currentIndexSpace = DdlHelp.toTablespace(alterTable.getIndexTablespace());
|
||||||
|
String currentLobSpace = DdlHelp.toTablespace(alterTable.getLobTablespace());
|
||||||
|
|
||||||
|
if (currentTableSpace != null) {
|
||||||
|
assert currentIndexSpace != null;
|
||||||
|
assert currentLobSpace != null;
|
||||||
|
table.setTablespaceMeta(new TablespaceMeta(currentTableSpace, currentIndexSpace, currentLobSpace));
|
||||||
|
} else {
|
||||||
|
assert currentIndexSpace == null;
|
||||||
|
assert currentLobSpace == null;
|
||||||
|
table.setTablespaceMeta(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a CreateTable change to the model.
|
* Apply a CreateTable change to the model.
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.ebeaninternal.dbmigration.migration.AddTableComment;
|
|||||||
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
import io.ebeaninternal.dbmigration.migration.AddUniqueConstraint;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
||||||
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
import io.ebeaninternal.dbmigration.migration.AlterForeignKey;
|
||||||
|
import io.ebeaninternal.dbmigration.migration.AlterTable;
|
||||||
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
||||||
import io.ebeaninternal.dbmigration.migration.ChangeSetType;
|
import io.ebeaninternal.dbmigration.migration.ChangeSetType;
|
||||||
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
import io.ebeaninternal.dbmigration.migration.CreateIndex;
|
||||||
@@ -252,4 +253,11 @@ public class ModelDiff {
|
|||||||
public void addAlterForeignKey(AlterForeignKey alterForeignKey) {
|
public void addAlterForeignKey(AlterForeignKey alterForeignKey) {
|
||||||
applyChanges.add(alterForeignKey);
|
applyChanges.add(alterForeignKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a table alter.
|
||||||
|
*/
|
||||||
|
public void addAlterTable(AlterTable alterTable) {
|
||||||
|
applyChanges.add(alterTable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -18,7 +18,7 @@ public class ModelBuildElementTable {
|
|||||||
|
|
||||||
BeanTable beanTable = manyProp.beanTable();
|
BeanTable beanTable = manyProp.beanTable();
|
||||||
BeanDescriptor<?> targetDescriptor = manyProp.targetDescriptor();
|
BeanDescriptor<?> targetDescriptor = manyProp.targetDescriptor();
|
||||||
MTable table = new MTable(beanTable.getBaseTable());
|
MTable table = new MTable(beanTable.getBaseTable(), manyProp.descriptor());
|
||||||
|
|
||||||
VisitProperties.visit(targetDescriptor, new ModelBuildPropertyVisitor(ctx, table, targetDescriptor));
|
VisitProperties.visit(targetDescriptor, new ModelBuildPropertyVisitor(ctx, table, targetDescriptor));
|
||||||
ctx.addTableElementCollection(table);
|
ctx.addTableElementCollection(table);
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ class ModelBuildIntersectionTable {
|
|||||||
BeanDescriptor<?> targetDesc = manyProp.targetDescriptor();
|
BeanDescriptor<?> targetDesc = manyProp.targetDescriptor();
|
||||||
|
|
||||||
String tableName = intersectionTableJoin.getTable();
|
String tableName = intersectionTableJoin.getTable();
|
||||||
MTable table = new MTable(tableName);
|
MTable table = new MTable(tableName, localDesc);
|
||||||
if (!manyProp.isExcludedFromHistory()) {
|
if (!manyProp.isExcludedFromHistory()) {
|
||||||
if (localDesc.isHistorySupport()) {
|
if (localDesc.isHistorySupport()) {
|
||||||
table.setWithHistory(true);
|
table.setWithHistory(true);
|
||||||
|
|||||||
@@ -218,6 +218,27 @@
|
|||||||
<xsd:attribute name="baseTable" type="xsd:string" use="required"/>
|
<xsd:attribute name="baseTable" type="xsd:string" use="required"/>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
|
|
||||||
|
<xsd:element name="alterTable">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required"/>
|
||||||
|
<xsd:attribute name="newName" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="partitionMode" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="partitionColumn" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="identityType" type="identityType"/>
|
||||||
|
<xsd:attribute name="identityStart" type="xsd:positiveInteger"/>
|
||||||
|
<xsd:attribute name="identityIncrement" type="xsd:positiveInteger"/>
|
||||||
|
<xsd:attribute name="identityCache" type="xsd:positiveInteger"/>
|
||||||
|
<xsd:attribute name="identityGenerated" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="sequenceName" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="sequenceInitial" type="xsd:positiveInteger"/>
|
||||||
|
<xsd:attribute name="sequenceAllocate" type="xsd:positiveInteger"/>
|
||||||
|
<xsd:attribute name="pkName" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="storageEngine" type="xsd:string"/>
|
||||||
|
<xsd:attributeGroup ref="tablespaceAttributes"/>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
|
||||||
|
|
||||||
<xsd:element name="dropHistoryTable">
|
<xsd:element name="dropHistoryTable">
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
@@ -341,6 +362,7 @@
|
|||||||
<xsd:attributeGroup name="tablespaceAttributes">
|
<xsd:attributeGroup name="tablespaceAttributes">
|
||||||
<xsd:attribute name="tablespace" type="xsd:string"/>
|
<xsd:attribute name="tablespace" type="xsd:string"/>
|
||||||
<xsd:attribute name="indexTablespace" type="xsd:string"/>
|
<xsd:attribute name="indexTablespace" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="lobTablespace" type="xsd:string"/>
|
||||||
<xsd:attribute name="comment" type="xsd:string"/>
|
<xsd:attribute name="comment" type="xsd:string"/>
|
||||||
</xsd:attributeGroup>
|
</xsd:attributeGroup>
|
||||||
|
|
||||||
@@ -351,6 +373,7 @@
|
|||||||
<xsd:element ref="sql" maxOccurs="unbounded"/>
|
<xsd:element ref="sql" maxOccurs="unbounded"/>
|
||||||
|
|
||||||
<xsd:element ref="createTable" maxOccurs="unbounded"/>
|
<xsd:element ref="createTable" maxOccurs="unbounded"/>
|
||||||
|
<xsd:element ref="alterTable" maxOccurs="unbounded"/>
|
||||||
<xsd:element ref="dropTable" maxOccurs="unbounded"/>
|
<xsd:element ref="dropTable" maxOccurs="unbounded"/>
|
||||||
<xsd:element ref="renameTable" maxOccurs="unbounded"/>
|
<xsd:element ref="renameTable" maxOccurs="unbounded"/>
|
||||||
<xsd:element ref="addTableComment" maxOccurs="unbounded"/>
|
<xsd:element ref="addTableComment" maxOccurs="unbounded"/>
|
||||||
|
|||||||
+8
@@ -109,4 +109,12 @@ public class PlatformDdl_CreateIndexTest {
|
|||||||
assertEquals("create index ix_mytab_acol on mytab (acol)", sql);
|
assertEquals("create index ix_mytab_acol on mytab (acol)", sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void db2luw_tablespaceIndex() {
|
||||||
|
String sql = db2LuwDdl.createIndex(new WriteCreateIndex("ix_mytab_acol", "mytab", new String[]{"acol"}, false));
|
||||||
|
assertEquals("create index ix_mytab_acol on mytab (acol)", sql);
|
||||||
|
sql = db2LuwDdl.createIndex(new WriteCreateIndex("ix_mytab_acol", "mytab", new String[]{"acol"}, true));
|
||||||
|
assertEquals("create unique index ix_mytab_acol on mytab (acol)", sql);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -34,8 +34,8 @@ public class ModelContainerApplyTest {
|
|||||||
|
|
||||||
MTable foo = model.getTable("foo");
|
MTable foo = model.getTable("foo");
|
||||||
assertThat(foo.getComment()).isEqualTo("comment");
|
assertThat(foo.getComment()).isEqualTo("comment");
|
||||||
assertThat(foo.getTablespace()).isEqualTo("fooSpace");
|
assertThat(foo.getTablespaceMeta().getTablespaceName()).isEqualTo("fooSpace");
|
||||||
assertThat(foo.getIndexTablespace()).isEqualTo("fooIndexSpace");
|
assertThat(foo.getTablespaceMeta().getIndexTablespace()).isEqualTo("fooIndexSpace");
|
||||||
assertThat(foo.isWithHistory()).isEqualTo(false);
|
assertThat(foo.isWithHistory()).isEqualTo(false);
|
||||||
assertThat(foo.allColumns()).extracting("name").contains("col1", "col3", "added_to_foo");
|
assertThat(foo.allColumns()).extracting("name").contains("col1", "col3", "added_to_foo");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,3 @@ datasource.db2.url=jdbc:db2://localhost:50005/migtest
|
|||||||
datasource.pg.username=sa
|
datasource.pg.username=sa
|
||||||
datasource.pg.password=
|
datasource.pg.password=
|
||||||
datasource.pg.url=jdbc:h2:mem:h2AutoTune
|
datasource.pg.url=jdbc:h2:mem:h2AutoTune
|
||||||
|
|
||||||
|
|
||||||
@@ -74,6 +74,10 @@ public class DbMigrationTest extends BaseTestCase {
|
|||||||
if (isSqlServer() || isMariaDB()) { // || isMySql()
|
if (isSqlServer() || isMariaDB()) { // || isMySql()
|
||||||
runScript("I__create_procs.sql");
|
runScript("I__create_procs.sql");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isDb2()) {
|
||||||
|
runScript("I__create_tablespaces.sql");
|
||||||
|
}
|
||||||
|
|
||||||
runScript("1.0__initial.sql");
|
runScript("1.0__initial.sql");
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import io.ebean.annotation.DbDefault;
|
|||||||
import io.ebean.annotation.EnumValue;
|
import io.ebean.annotation.EnumValue;
|
||||||
import io.ebean.annotation.Index;
|
import io.ebean.annotation.Index;
|
||||||
import io.ebean.annotation.NotNull;
|
import io.ebean.annotation.NotNull;
|
||||||
|
import io.ebean.annotation.Tablespace;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
@@ -14,6 +15,7 @@ import java.sql.Timestamp;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "migtest_e_basic")
|
@Table(name = "migtest_e_basic")
|
||||||
|
@Tablespace(value = "TSTABLES", index = "INDEXTS")
|
||||||
public class EBasic {
|
public class EBasic {
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
|
|||||||
@@ -4,10 +4,14 @@ import javax.persistence.Entity;
|
|||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import io.ebean.annotation.Tablespace;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "migtest_mtm_c")
|
@Table(name = "migtest_mtm_c")
|
||||||
|
@Tablespace("TESTTS")
|
||||||
public class MtmChild {
|
public class MtmChild {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
|||||||
@@ -5,10 +5,14 @@ import javax.persistence.Entity;
|
|||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import io.ebean.annotation.Tablespace;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "migtest_mtm_m")
|
@Table(name = "migtest_mtm_m")
|
||||||
|
@Tablespace("TSMASTER")
|
||||||
public class MtmMaster {
|
public class MtmMaster {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
|||||||
-1
@@ -5,7 +5,6 @@ import io.ebean.CountDistinctOrder;
|
|||||||
import io.ebean.DB;
|
import io.ebean.DB;
|
||||||
import io.ebean.Query;
|
import io.ebean.Query;
|
||||||
import io.ebean.annotation.Identity;
|
import io.ebean.annotation.Identity;
|
||||||
import io.ebean.annotation.Platform;
|
|
||||||
import io.ebeaninternal.api.SpiEbeanServer;
|
import io.ebeaninternal.api.SpiEbeanServer;
|
||||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||||
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||||
|
|||||||
@@ -72,5 +72,36 @@ call SYSPROC.SYSINSTALLOBJECTS( 'EXPLAIN', 'C' , '', CURRENT SCHEMA );
|
|||||||
END IF;
|
END IF;
|
||||||
END;$$
|
END;$$
|
||||||
</ddl-script>
|
</ddl-script>
|
||||||
|
|
||||||
|
<ddl-script name="create tablespaces" platforms="db2luw" init="true">
|
||||||
|
delimiter $$
|
||||||
|
BEGIN
|
||||||
|
IF (NOT exists (SELECT * FROM SYSIBM.SYSTABLESPACES WHERE TBSPACE = 'TSTABLES')) THEN
|
||||||
|
EXECUTE IMMEDIATE 'CREATE TABLESPACE "TSTABLES"';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
delimiter $$
|
||||||
|
BEGIN
|
||||||
|
IF (NOT exists (SELECT * FROM SYSIBM.SYSTABLESPACES WHERE TBSPACE = 'INDEXTS'))
|
||||||
|
THEN EXECUTE IMMEDIATE 'CREATE TABLESPACE "INDEXTS"';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
delimiter $$
|
||||||
|
BEGIN
|
||||||
|
IF (NOT exists (SELECT * FROM SYSIBM.SYSTABLESPACES WHERE TBSPACE = 'TESTTS')) THEN
|
||||||
|
EXECUTE IMMEDIATE 'CREATE TABLESPACE "TESTTS"';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
delimiter $$
|
||||||
|
BEGIN
|
||||||
|
IF (NOT exists (SELECT * FROM SYSIBM.SYSTABLESPACES WHERE TBSPACE = 'TSMASTER')) THEN
|
||||||
|
EXECUTE IMMEDIATE 'CREATE TABLESPACE "TSMASTER"';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
</ddl-script>
|
||||||
|
|
||||||
</extra-ddl>
|
</extra-ddl>
|
||||||
@@ -74,7 +74,7 @@ create table migtest_e_basic (
|
|||||||
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
|
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
|
||||||
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
|
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
|
||||||
constraint pk_migtest_e_basic primary key (id)
|
constraint pk_migtest_e_basic primary key (id)
|
||||||
);
|
) in TSTABLES index in INDEXTS long in TSTABLES;
|
||||||
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
|
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
|
||||||
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
|
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
|
||||||
|
|
||||||
|
|||||||
@@ -9,18 +9,18 @@ create table migtest_mtm_c_migtest_mtm_m (
|
|||||||
migtest_mtm_c_id integer not null,
|
migtest_mtm_c_id integer not null,
|
||||||
migtest_mtm_m_id bigint not null,
|
migtest_mtm_m_id bigint not null,
|
||||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||||
);
|
) in TESTTS index in TESTTS long in TESTTS;
|
||||||
|
|
||||||
create table migtest_mtm_m_migtest_mtm_c (
|
create table migtest_mtm_m_migtest_mtm_c (
|
||||||
migtest_mtm_m_id bigint not null,
|
migtest_mtm_m_id bigint not null,
|
||||||
migtest_mtm_c_id integer not null,
|
migtest_mtm_c_id integer not null,
|
||||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||||
);
|
) in TSMASTER index in TSMASTER long in TSMASTER;
|
||||||
|
|
||||||
create table migtest_mtm_m_phone_numbers (
|
create table migtest_mtm_m_phone_numbers (
|
||||||
migtest_mtm_m_id bigint not null,
|
migtest_mtm_m_id bigint not null,
|
||||||
value varchar(255) not null
|
value varchar(255) not null
|
||||||
);
|
) in TSMASTER index in TSMASTER long in TSMASTER;
|
||||||
|
|
||||||
alter table migtest_ckey_detail add column one_key integer;
|
alter table migtest_ckey_detail add column one_key integer;
|
||||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||||
@@ -119,6 +119,7 @@ create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(stat
|
|||||||
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
|
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
|
||||||
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
|
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
|
||||||
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
|
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
|
||||||
|
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_E_BASIC','USERSPACE1','USERSPACE1','USERSPACE1','','','','','','MOVE');
|
||||||
delimiter $$
|
delimiter $$
|
||||||
begin
|
begin
|
||||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then
|
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then
|
||||||
@@ -152,6 +153,8 @@ alter table migtest_e_history6 alter column test_number1 set not null;
|
|||||||
alter table migtest_e_history6 alter column test_number2 drop not null;
|
alter table migtest_e_history6 alter column test_number2 drop not null;
|
||||||
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
||||||
|
|
||||||
|
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','TESTTS','TESTTS','TESTTS','','','','','','MOVE');
|
||||||
|
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','TSMASTER','TSMASTER','TSMASTER','','','','','','MOVE');
|
||||||
alter table migtest_oto_child add column master_id bigint;
|
alter table migtest_oto_child add column master_id bigint;
|
||||||
|
|
||||||
call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #6 */;
|
call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #6 */;
|
||||||
|
|||||||
@@ -183,6 +183,8 @@ call sysproc.admin_cmd('reorg table migtest_e_history4') /* reorg #6 */;
|
|||||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
||||||
alter table migtest_e_history6 alter column test_number2 set default 7;
|
alter table migtest_e_history6 alter column test_number2 set default 7;
|
||||||
alter table migtest_e_history6 alter column test_number2 set not null;
|
alter table migtest_e_history6 alter column test_number2 set not null;
|
||||||
|
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','USERSPACE1','USERSPACE1','USERSPACE1','','','','','','MOVE');
|
||||||
|
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','USERSPACE1','USERSPACE1','USERSPACE1','','','','','','MOVE');
|
||||||
call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #7 */;
|
call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #7 */;
|
||||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
delimiter $$
|
||||||
|
BEGIN
|
||||||
|
IF (NOT exists (SELECT * FROM SYSIBM.SYSTABLESPACES WHERE TBSPACE = 'TSTABLES')) THEN
|
||||||
|
EXECUTE IMMEDIATE 'CREATE TABLESPACE "TSTABLES"';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
delimiter $$
|
||||||
|
BEGIN
|
||||||
|
IF (NOT exists (SELECT * FROM SYSIBM.SYSTABLESPACES WHERE TBSPACE = 'INDEXTS'))
|
||||||
|
THEN EXECUTE IMMEDIATE 'CREATE TABLESPACE "INDEXTS"';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
delimiter $$
|
||||||
|
BEGIN
|
||||||
|
IF (NOT exists (SELECT * FROM SYSIBM.SYSTABLESPACES WHERE TBSPACE = 'TESTTS')) THEN
|
||||||
|
EXECUTE IMMEDIATE 'CREATE TABLESPACE "TESTTS"';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
delimiter $$
|
||||||
|
BEGIN
|
||||||
|
IF (NOT exists (SELECT * FROM SYSIBM.SYSTABLESPACES WHERE TBSPACE = 'TSMASTER')) THEN
|
||||||
|
EXECUTE IMMEDIATE 'CREATE TABLESPACE "TSMASTER"';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
1580812656, 1.0__initial.sql
|
-1602289007, I__create_tablespaces.sql
|
||||||
-2144208808, 1.1.sql
|
999346633, 1.0__initial.sql
|
||||||
|
2079409430, 1.1.sql
|
||||||
1091886546, 1.2__dropsFor_1.1.sql
|
1091886546, 1.2__dropsFor_1.1.sql
|
||||||
-1041850370, 1.3.sql
|
-1291483335, 1.3.sql
|
||||||
1293885677, 1.4__dropsFor_1.3.sql
|
1293885677, 1.4__dropsFor_1.3.sql
|
||||||
-133543359, R__db2_explain_tables.sql
|
-133543359, R__db2_explain_tables.sql
|
||||||
561281075, R__order_views.sql
|
561281075, R__order_views.sql
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@
|
|||||||
<column name="id" type="bigint" primaryKey="true"/>
|
<column name="id" type="bigint" primaryKey="true"/>
|
||||||
<column name="one_id" type="bigint" references="migtest_fk_one.id" foreignKeyName="fk_migtest_fk_set_null_one_id" foreignKeyIndex="ix_migtest_fk_set_null_one_id" foreignKeyOnDelete="SET_NULL" foreignKeyOnUpdate="RESTRICT"/>
|
<column name="one_id" type="bigint" references="migtest_fk_one.id" foreignKeyName="fk_migtest_fk_set_null_one_id" foreignKeyIndex="ix_migtest_fk_set_null_one_id" foreignKeyOnDelete="SET_NULL" foreignKeyOnUpdate="RESTRICT"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable name="migtest_e_basic" pkName="pk_migtest_e_basic">
|
<createTable name="migtest_e_basic" pkName="pk_migtest_e_basic" tablespace="TSTABLES" indexTablespace="INDEXTS" lobTablespace="TSTABLES">
|
||||||
<column name="id" type="integer" primaryKey="true"/>
|
<column name="id" type="integer" primaryKey="true"/>
|
||||||
<column name="status" type="varchar(1)" checkConstraint="check ( status in ('N','A','I'))" checkConstraintName="ck_migtest_e_basic_status"/>
|
<column name="status" type="varchar(1)" checkConstraint="check ( status in ('N','A','I'))" checkConstraintName="ck_migtest_e_basic_status"/>
|
||||||
<column name="status2" type="varchar(1)" defaultValue="'N'" notnull="true" checkConstraint="check ( status2 in ('N','A','I'))" checkConstraintName="ck_migtest_e_basic_status2"/>
|
<column name="status2" type="varchar(1)" defaultValue="'N'" notnull="true" checkConstraint="check ( status2 in ('N','A','I'))" checkConstraintName="ck_migtest_e_basic_status2"/>
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_name" tableName="migtest_e_basic" columnNames="name" oneToOne="false" nullableColumns="name"/>
|
<addUniqueConstraint constraintName="uq_migtest_e_basic_name" tableName="migtest_e_basic" columnNames="name" oneToOne="false" nullableColumns="name"/>
|
||||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest4" tableName="migtest_e_basic" columnNames="indextest4" oneToOne="false" nullableColumns="indextest4"/>
|
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest4" tableName="migtest_e_basic" columnNames="indextest4" oneToOne="false" nullableColumns="indextest4"/>
|
||||||
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest5" tableName="migtest_e_basic" columnNames="indextest5" oneToOne="false" nullableColumns="indextest5"/>
|
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest5" tableName="migtest_e_basic" columnNames="indextest5" oneToOne="false" nullableColumns="indextest5"/>
|
||||||
|
<alterTable name="migtest_e_basic" tablespace="$TABLESPACE_DEFAULT" indexTablespace="$TABLESPACE_DEFAULT" lobTablespace="$TABLESPACE_DEFAULT"/>
|
||||||
<alterColumn columnName="test_status" tableName="migtest_e_enum" dropCheckConstraint="ck_migtest_e_enum_test_status"/>
|
<alterColumn columnName="test_status" tableName="migtest_e_enum" dropCheckConstraint="ck_migtest_e_enum_test_status"/>
|
||||||
<addHistoryTable baseTable="migtest_e_history"/>
|
<addHistoryTable baseTable="migtest_e_history"/>
|
||||||
<alterColumn columnName="test_string" tableName="migtest_e_history" type="bigint" currentType="varchar" currentNotnull="false" comment="Column altered to long now">
|
<alterColumn columnName="test_string" tableName="migtest_e_history" type="bigint" currentType="varchar" currentNotnull="false" comment="Column altered to long now">
|
||||||
@@ -81,19 +82,21 @@
|
|||||||
<createTable name="migtest_e_user" pkName="pk_migtest_e_user">
|
<createTable name="migtest_e_user" pkName="pk_migtest_e_user">
|
||||||
<column name="id" type="integer" primaryKey="true"/>
|
<column name="id" type="integer" primaryKey="true"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable name="migtest_mtm_c_migtest_mtm_m" pkName="pk_migtest_mtm_c_migtest_mtm_m">
|
<alterTable name="migtest_mtm_c" tablespace="TESTTS" indexTablespace="TESTTS" lobTablespace="TESTTS"/>
|
||||||
|
<createTable name="migtest_mtm_c_migtest_mtm_m" pkName="pk_migtest_mtm_c_migtest_mtm_m" tablespace="TESTTS" indexTablespace="TESTTS" lobTablespace="TESTTS">
|
||||||
<column name="migtest_mtm_c_id" type="integer" notnull="true" primaryKey="true"/>
|
<column name="migtest_mtm_c_id" type="integer" notnull="true" primaryKey="true"/>
|
||||||
<column name="migtest_mtm_m_id" type="bigint" notnull="true" primaryKey="true"/>
|
<column name="migtest_mtm_m_id" type="bigint" notnull="true" primaryKey="true"/>
|
||||||
<foreignKey name="fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c" columnNames="migtest_mtm_c_id" refColumnNames="id" refTableName="migtest_mtm_c" indexName="ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c"/>
|
<foreignKey name="fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c" columnNames="migtest_mtm_c_id" refColumnNames="id" refTableName="migtest_mtm_c" indexName="ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c"/>
|
||||||
<foreignKey name="fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m" columnNames="migtest_mtm_m_id" refColumnNames="id" refTableName="migtest_mtm_m" indexName="ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m"/>
|
<foreignKey name="fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m" columnNames="migtest_mtm_m_id" refColumnNames="id" refTableName="migtest_mtm_m" indexName="ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable name="migtest_mtm_m_migtest_mtm_c" pkName="pk_migtest_mtm_m_migtest_mtm_c">
|
<alterTable name="migtest_mtm_m" tablespace="TSMASTER" indexTablespace="TSMASTER" lobTablespace="TSMASTER"/>
|
||||||
|
<createTable name="migtest_mtm_m_migtest_mtm_c" pkName="pk_migtest_mtm_m_migtest_mtm_c" tablespace="TSMASTER" indexTablespace="TSMASTER" lobTablespace="TSMASTER">
|
||||||
<column name="migtest_mtm_m_id" type="bigint" notnull="true" primaryKey="true"/>
|
<column name="migtest_mtm_m_id" type="bigint" notnull="true" primaryKey="true"/>
|
||||||
<column name="migtest_mtm_c_id" type="integer" notnull="true" primaryKey="true"/>
|
<column name="migtest_mtm_c_id" type="integer" notnull="true" primaryKey="true"/>
|
||||||
<foreignKey name="fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m" columnNames="migtest_mtm_m_id" refColumnNames="id" refTableName="migtest_mtm_m" indexName="ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m"/>
|
<foreignKey name="fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m" columnNames="migtest_mtm_m_id" refColumnNames="id" refTableName="migtest_mtm_m" indexName="ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m"/>
|
||||||
<foreignKey name="fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c" columnNames="migtest_mtm_c_id" refColumnNames="id" refTableName="migtest_mtm_c" indexName="ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c"/>
|
<foreignKey name="fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c" columnNames="migtest_mtm_c_id" refColumnNames="id" refTableName="migtest_mtm_c" indexName="ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable name="migtest_mtm_m_phone_numbers" pkName="pk_migtest_mtm_m_phone_numbers">
|
<createTable name="migtest_mtm_m_phone_numbers" pkName="pk_migtest_mtm_m_phone_numbers" tablespace="TSMASTER" indexTablespace="TSMASTER" lobTablespace="TSMASTER">
|
||||||
<column name="migtest_mtm_m_id" type="bigint" notnull="true" references="migtest_mtm_m.id" foreignKeyName="fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id" foreignKeyIndex="ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id"/>
|
<column name="migtest_mtm_m_id" type="bigint" notnull="true" references="migtest_mtm_m.id" foreignKeyName="fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id" foreignKeyIndex="ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id"/>
|
||||||
<column name="value" type="varchar" notnull="true"/>
|
<column name="value" type="varchar" notnull="true"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|||||||
@@ -38,6 +38,8 @@
|
|||||||
<column name="name" type="varchar(127)" notnull="true"/>
|
<column name="name" type="varchar(127)" notnull="true"/>
|
||||||
<uniqueConstraint name="uq_migtest_e_ref_name" columnNames="name" oneToOne="false" nullableColumns=""/>
|
<uniqueConstraint name="uq_migtest_e_ref_name" columnNames="name" oneToOne="false" nullableColumns=""/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
<alterTable name="migtest_mtm_c" tablespace="$TABLESPACE_DEFAULT" indexTablespace="$TABLESPACE_DEFAULT" lobTablespace="$TABLESPACE_DEFAULT"/>
|
||||||
|
<alterTable name="migtest_mtm_m" tablespace="$TABLESPACE_DEFAULT" indexTablespace="$TABLESPACE_DEFAULT" lobTablespace="$TABLESPACE_DEFAULT"/>
|
||||||
<addUniqueConstraint constraintName="uq_m12_otoc72" tableName="migtest_oto_child" columnNames="name" oneToOne="false" nullableColumns="name" platforms="MYSQL"/>
|
<addUniqueConstraint constraintName="uq_m12_otoc72" tableName="migtest_oto_child" columnNames="name" oneToOne="false" nullableColumns="name" platforms="MYSQL"/>
|
||||||
<addUniqueConstraint constraintName="uq_migtest_oto_master_name" tableName="migtest_oto_master" columnNames="name" oneToOne="false" nullableColumns="name" platforms="MYSQL"/>
|
<addUniqueConstraint constraintName="uq_migtest_oto_master_name" tableName="migtest_oto_master" columnNames="name" oneToOne="false" nullableColumns="name" platforms="MYSQL"/>
|
||||||
<createIndex indexName="ix_migtest_e_basic_indextest1" tableName="migtest_e_basic" columns="indextest1"/>
|
<createIndex indexName="ix_migtest_e_basic_indextest1" tableName="migtest_e_basic" columns="indextest1"/>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
ebean.test.platform=db2
|
ebean.test.platform=db2
|
||||||
ebean.test.dbName=unit
|
ebean.test.dbName=unit
|
||||||
ebean.test.dbPassword=unit
|
# we need admin user to call the procedure SYSPROC.ADMIN_MOVE_TABLE
|
||||||
|
ebean.test.username=admin
|
||||||
|
ebean.test.password=admin
|
||||||
datasource.default=db2-11
|
datasource.default=db2-11
|
||||||
ebean.db2-11.databasePlatformName=db2luw
|
ebean.db2-11.databasePlatformName=db2luw
|
||||||
@@ -4,3 +4,8 @@ We @foconis use this command to release.
|
|||||||
|
|
||||||
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=12.14.2-FOC1-SNAPSHOT
|
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=12.14.2-FOC1-SNAPSHOT
|
||||||
mvn release:prepare release:perform -Darguments="-Dgpg.skip -DskipTests"
|
mvn release:prepare release:perform -Darguments="-Dgpg.skip -DskipTests"
|
||||||
|
|
||||||
|
generate Java classes from .xsd:
|
||||||
|
|
||||||
|
export JAVA_TOOL_OPTIONS="-Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8"
|
||||||
|
/c/Program\ Files/Java/jdk1.8.0_201/bin/xjc.exe src/main/resources/ebean-dbmigration-1.0.xsd -d src/main/java -p io.ebeaninternal.dbmigration.migration
|
||||||
Reference in new issue
Block a user