package io.ebeaninternal.dbmigration.ddlgeneration.platform;

import io.ebean.annotation.ConstraintMode;
import io.ebean.config.dbplatform.DatabasePlatform;

DB2 platform specific DDL.
/** * DB2 platform specific DDL. */
public class DB2Ddl extends PlatformDdl { public DB2Ddl(DatabasePlatform platform) { super(platform); this.dropTableIfExists = "drop table "; this.dropSequenceIfExists = "drop sequence "; this.dropConstraintIfExists = "drop constraint"; this.dropIndexIfExists = "drop index "; this.identitySuffix = " generated by default as identity"; this.inlineUniqueWhenNullable = false; } @Override public String alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns, String[] nullableColumns) { if (nullableColumns == null || nullableColumns.length == 0) { return super.alterTableAddUniqueConstraint(tableName, uqName, columns, nullableColumns); } else { // Hmm: Complex workaround: https://www.ibm.com/developerworks/mydeveloperworks/blogs/SQLTips4DB2LUW/entry/unique_where_not_null_indexes26?lang=en return "-- NOT SUPPORTED " + super.alterTableAddUniqueConstraint(tableName, uqName, columns, nullableColumns); } } @Override protected void appendForeignKeyOnUpdate(StringBuilder buffer, ConstraintMode mode) { // do nothing, no on update clause for db2 } }