mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
Fix: Migration problems
This commit is contained in:
1 parent
e252ff4932
commit
d37bf4634a
8 files changed
+185
-133
No files matched your search
+11
-15
@@ -238,8 +238,7 @@ public class BaseTableDdl implements TableDdl {
|
||||
}
|
||||
apply.newLine().append(")");
|
||||
if (createTable.getTablespace() != null) {
|
||||
platformDdl.addTablespace(apply, createTable.getTablespace(), createTable.getIndexTablespace(),
|
||||
createTable.getLobTablespace());
|
||||
platformDdl.addTablespace(apply, createTable.getTablespace(), createTable.getIndexTablespace(), createTable.getLobTablespace());
|
||||
}
|
||||
addTableStorageEngine(apply, createTable);
|
||||
addTableCommentInline(apply, createTable);
|
||||
@@ -666,25 +665,22 @@ public class BaseTableDdl implements TableDdl {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add table related changes to DDL (tableSpace,...)
|
||||
*/
|
||||
@Override
|
||||
public void generate(DdlWrite writer, AlterTable alterTable) {
|
||||
if (hasValue(alterTable.getTablespace()) || hasValue(alterTable.getIndexTablespace()) || hasValue(alterTable.getLobTablespace())) {
|
||||
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())));
|
||||
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) {
|
||||
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.
|
||||
*/
|
||||
|
||||
+9
-38
@@ -12,28 +12,6 @@ import io.ebeaninternal.dbmigration.migration.Column;
|
||||
|
||||
/**
|
||||
* DB2 platform specific DDL.
|
||||
*
|
||||
* according to the list
|
||||
* https://datageek.blog/en/2014/05/06/db2-basics-what-is-a-reorg/ a reorg is
|
||||
* necessary after
|
||||
* <ol>
|
||||
* <li>Data type changes that increase the size of a varchar or vargraphic
|
||||
* column
|
||||
* <li>Data type changes that decrease the size of a varchar or vargraphic
|
||||
* column
|
||||
* <li>Altering a column to include NOT NULL
|
||||
* <li>Altering a column to inline LOBS
|
||||
* <li>Altering a column to compress the system default or turn off compression
|
||||
* for the system default
|
||||
* <li>Altering a table to enable value compression
|
||||
* <li>Altering a table to drop a column
|
||||
* <li>Changing the PCTFREE for a table
|
||||
* <li>Altering a table to turn APEND mode off
|
||||
* <li>Altering a table or index to turn compression on
|
||||
* </ol>
|
||||
*
|
||||
* This is currently handled by BaseTableDdl
|
||||
*
|
||||
*/
|
||||
public class DB2Ddl extends PlatformDdl {
|
||||
private static final String MOVE_TABLE = "CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'%s','%s','%s','%s','','','','','','MOVE')";
|
||||
@@ -62,39 +40,32 @@ public class DB2Ddl extends PlatformDdl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns,
|
||||
String[] nullableColumns) {
|
||||
StringBuilder sb = new StringBuilder(300);
|
||||
public String alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns, String[] nullableColumns) {
|
||||
if (nullableColumns == null || nullableColumns.length == 0) {
|
||||
|
||||
sb.append("alter table ").append(lowerTableName(tableName));
|
||||
sb.append(" add constraint ").append(maxConstraintName(uqName)).append(" unique ");
|
||||
appendColumns(columns, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
return super.alterTableAddUniqueConstraint(tableName, uqName, columns, nullableColumns);
|
||||
}
|
||||
|
||||
if (uqName == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
sb = new StringBuilder("create unique index ");
|
||||
StringBuilder sb = new StringBuilder("create unique index ");
|
||||
sb.append(maxConstraintName(uqName)).append(" on ").append(tableName).append('(');
|
||||
|
||||
for (int i = 0; i < columns.length; i++) {
|
||||
if (i > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(lowerColumnName(columns[i]));
|
||||
sb.append(columns[i]);
|
||||
}
|
||||
sb.append(") exclude null keys");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
// @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);
|
||||
// }
|
||||
@Override
|
||||
public void addTablespace(DdlBuffer apply, String tablespaceName, String indexTablespace, String lobTablespace) {
|
||||
apply.append(" in ").append(tablespaceName).append(" index in ").append(indexTablespace).append(" long in ").append(lobTablespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void alterTableAddColumn(DdlWrite writer, String tableName, Column column, boolean onHistoryTable, String defaultValue) {
|
||||
|
||||
-10
@@ -813,14 +813,4 @@ public class PlatformDdl {
|
||||
// now only supported for db2
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a statement to reorganize the table. This is required mainly for DB2.
|
||||
*
|
||||
* @param table the table name
|
||||
* @param counter to make statements unique.
|
||||
*/
|
||||
public String reorgTable(String table, int counter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-7
@@ -187,13 +187,12 @@ public class ObjectFactory {
|
||||
return new ChangeSet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link AlterTable }
|
||||
*
|
||||
*/
|
||||
public AlterTable createAlterTable() {
|
||||
return new AlterTable();
|
||||
}
|
||||
/**
|
||||
* Create an instance of {@link AlterTable }
|
||||
*/
|
||||
public AlterTable createAlterTable() {
|
||||
return new AlterTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link AddHistoryTable }
|
||||
|
||||
+3
-1
@@ -266,7 +266,9 @@ public class ModelContainer {
|
||||
tables.remove(dropTable.getName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply a AlterTable change to the model.
|
||||
*/
|
||||
protected void applyChange(AlterTable alterTable) {
|
||||
MTable table = getTable(alterTable.getName());
|
||||
if (table == null) {
|
||||
|
||||
Reference in new issue
Block a user