Class PlatformDdl
java.lang.Object
io.ebeaninternal.dbmigration.ddlgeneration.platform.PlatformDdl
- Direct Known Subclasses:
AbstractHanaDdl,ClickHouseDdl,CockroachDdl,DB2Ddl,H2Ddl,HsqldbDdl,MySqlDdl,NuoDbDdl,OracleDdl,PostgresDdl,SQLiteDdl,SqlServerDdl
Controls the DDL generation for a specific database platform.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumnComment(DdlBuffer apply, String table, String column, String comment)Add column comment as a separate statement.voidaddHistoryTable(DdlWrite writer, AddHistoryTable addHistoryTable)Add history support to an existing table.voidaddTableComment(DdlBuffer apply, String tableName, String tableComment)Add table comment as a separate statement (from the create table statement).voidaddTablePartition(DdlBuffer apply, String partitionMode, String partitionColumn)alterColumnBaseAttributes(AlterColumn alter)Alter column setting both the type and not null constraint.alterColumnDefaultValue(String tableName, String columnName, String defaultValue)Alter column setting the default value.alterColumnNotnull(String tableName, String columnName, boolean notnull)Alter a column adding or removing the not null constraint.alterColumnType(String tableName, String columnName, String type)Alter a column type.alterTableAddCheckConstraint(String tableName, String checkConstraintName, String checkConstraint)Alter table adding the check constraint.voidalterTableAddColumn(DdlBuffer buffer, String tableName, Column column, boolean onHistoryTable, String defaultValue)alterTableAddForeignKey(DdlOptions options, io.ebeaninternal.dbmigration.ddlgeneration.platform.WriteForeignKey request)Add foreign key.alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns, String[] nullableColumns)Add a unique constraint to the table.voidalterTableDropColumn(DdlBuffer buffer, String tableName, String columnName)alterTableDropConstraint(String tableName, String constraintName)Drop a unique constraint from the table.alterTableDropForeignKey(String tableName, String fkName)Return the drop foreign key clause.alterTableDropUniqueConstraint(String tableName, String uniqueConstraintName)Drop a unique constraint from the table (Sometimes this is an index).asIdentityColumn(String columnDefn, DdlIdentity identity)Modify and return the column definition for autoincrement or identity definition.voidconfigure(io.ebean.config.DatabaseConfig config)Set configuration options.Convert the standard type to the platform specific type.convertDefaultValue(String dbDefault)Convert the DB column default literal to platform specific.createCheckConstraint(String ckName, String checkConstraint)Returns the check constraint.createDdlHandler(io.ebean.config.DatabaseConfig config)Create a DdlHandler for the specific database platform.createIndex(io.ebeaninternal.dbmigration.ddlgeneration.platform.WriteCreateIndex create)createSequence(String sequenceName, DdlIdentity identity)Generate and return the create sequence DDL.voidcreateWithHistory(DdlWrite writer, MTable table)Add history support to this table using the platform specific mechanism.voiddropHistoryTable(DdlWrite writer, DropHistoryTable dropHistoryTable)Drop history support for a given table.Return the drop index statement for known non concurrent index.Return the drop index statement.dropSequence(String sequenceName)Return the drop sequence statement (potentially with if exists clause).Return the drop table statement (potentially with if exists clause).voidgenerateEpilog(DdlWrite write)Use this to generate an epilog.voidgenerateProlog(DdlWrite write)Use this to generate a prolog for each script (stored procedures)Returns the database-specific "create table" command prefix.io.ebean.config.dbplatform.DatabasePlatformvoidinlineTableComment(DdlBuffer apply, String tableComment)Add an inline table comment to the create table statement.booleanReturn true if the platform includes storage engine clause.booleanReturn true if the table and column comments are included inline.booleanReturn true if foreign key reference constraints need to inlined with create table.booleanReturn true if unique constraints for nullable columns can be inlined as normal.voidlockTables(DdlBuffer buffer, Collection<String> tables)Mysql-specific: Locks all tables for triggers that have to be updated.voidregenerateHistoryTriggers(DdlWrite write, HistoryTableUpdate update)Regenerate the history triggers (or function) due to a column being added/dropped/excluded or included.setLockTimeout(int lockTimeoutSeconds)By default this does nothing returning null / no lock timeout.booleantableInlineForeignKey(io.ebeaninternal.dbmigration.ddlgeneration.platform.WriteForeignKey request)Return the foreign key constraint when used inline with create table.voidtableStorageEngine(DdlBuffer apply, String storageEngine)Add an table storage engine to the create table statement.voidunlockTables(DdlBuffer buffer, Collection<String> tables)Mysql-specific: Unlocks all tables for triggers that have to be updated.io.ebean.config.dbplatform.IdTypeuseIdentityType(io.ebean.config.dbplatform.IdType modelIdentity)Return the identity type to use given the support in the underlying database platform for sequences and identity/autoincrement.voidwriteTableColumns(DdlBuffer apply, List<Column> columns, DdlIdentity identity)Write all the table columns converting to platform types as necessary.
-
Constructor Details
-
PlatformDdl
-
-
Method Details
-
configure
Set configuration options. -
createDdlHandler
Create a DdlHandler for the specific database platform. -
useIdentityType
public io.ebean.config.dbplatform.IdType useIdentityType(io.ebean.config.dbplatform.IdType modelIdentity)Return the identity type to use given the support in the underlying database platform for sequences and identity/autoincrement. -
asIdentityColumn
Modify and return the column definition for autoincrement or identity definition. -
isInlineComments
Return true if the table and column comments are included inline. -
isIncludeStorageEngine
Return true if the platform includes storage engine clause. -
isInlineForeignKeys
Return true if foreign key reference constraints need to inlined with create table. Ideally we don't do this as then the constraints are not named. Do this for SQLite. -
setLockTimeout
By default this does nothing returning null / no lock timeout. -
writeTableColumns
public void writeTableColumns(DdlBuffer apply, List<Column> columns, DdlIdentity identity) throws IOExceptionWrite all the table columns converting to platform types as necessary.- Throws:
IOException
-
createCheckConstraint
Returns the check constraint. -
convertDefaultValue
Convert the DB column default literal to platform specific. -
alterTableDropForeignKey
Return the drop foreign key clause. -
convert
Convert the standard type to the platform specific type. -
createWithHistory
Add history support to this table using the platform specific mechanism.- Throws:
IOException
-
dropHistoryTable
public void dropHistoryTable(DdlWrite writer, DropHistoryTable dropHistoryTable) throws IOExceptionDrop history support for a given table.- Throws:
IOException
-
addHistoryTable
Add history support to an existing table.- Throws:
IOException
-
regenerateHistoryTriggers
public void regenerateHistoryTriggers(DdlWrite write, HistoryTableUpdate update) throws IOExceptionRegenerate the history triggers (or function) due to a column being added/dropped/excluded or included.- Throws:
IOException
-
createSequence
Generate and return the create sequence DDL. -
dropSequence
Return the drop sequence statement (potentially with if exists clause). -
dropTable
Return the drop table statement (potentially with if exists clause). -
dropIndex
Return the drop index statement for known non concurrent index. -
dropIndex
Return the drop index statement. -
createIndex
public String createIndex(io.ebeaninternal.dbmigration.ddlgeneration.platform.WriteCreateIndex create) -
tableInlineForeignKey
public String tableInlineForeignKey(io.ebeaninternal.dbmigration.ddlgeneration.platform.WriteForeignKey request)Return the foreign key constraint when used inline with create table. -
alterTableAddForeignKey
public String alterTableAddForeignKey(DdlOptions options, io.ebeaninternal.dbmigration.ddlgeneration.platform.WriteForeignKey request)Add foreign key. -
alterTableDropUniqueConstraint
Drop a unique constraint from the table (Sometimes this is an index). -
alterTableDropConstraint
Drop a unique constraint from the table. -
alterTableAddUniqueConstraint
public String alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns, String[] nullableColumns)Add a unique constraint to the table.Overridden by MsSqlServer for specific null handling on unique constraints.
-
alterTableAddColumn
public void alterTableAddColumn(DdlBuffer buffer, String tableName, Column column, boolean onHistoryTable, String defaultValue) throws IOException- Throws:
IOException
-
alterTableDropColumn
public void alterTableDropColumn(DdlBuffer buffer, String tableName, String columnName) throws IOException- Throws:
IOException
-
isInlineUniqueWhenNullable
Return true if unique constraints for nullable columns can be inlined as normal. Returns false for MsSqlServer and DB2 due to it's not possible to to put a constraint on a nullable column -
alterColumnType
Alter a column type.Note that that MySql and SQL Server instead use alterColumnBaseAttributes()
-
alterColumnNotnull
Alter a column adding or removing the not null constraint.Note that that MySql, SQL Server, and HANA instead use alterColumnBaseAttributes()
-
alterTableAddCheckConstraint
public String alterTableAddCheckConstraint(String tableName, String checkConstraintName, String checkConstraint)Alter table adding the check constraint. -
alterColumnDefaultValue
Alter column setting the default value. -
alterColumnBaseAttributes
Alter column setting both the type and not null constraint.Used by MySql, SQL Server, and HANA as these require both column attributes to be set together.
-
getPlatform
-
getUpdateNullWithDefault
-
inlineTableComment
Add an inline table comment to the create table statement.- Throws:
IOException
-
tableStorageEngine
Add an table storage engine to the create table statement.- Throws:
IOException
-
addTableComment
public void addTableComment(DdlBuffer apply, String tableName, String tableComment) throws IOExceptionAdd table comment as a separate statement (from the create table statement).- Throws:
IOException
-
addColumnComment
public void addColumnComment(DdlBuffer apply, String table, String column, String comment) throws IOExceptionAdd column comment as a separate statement.- Throws:
IOException
-
generateProlog
Use this to generate a prolog for each script (stored procedures)- Throws:
IOException
-
generateEpilog
Use this to generate an epilog. Will be added at the end of script- Throws:
IOException
-
lockTables
Mysql-specific: Locks all tables for triggers that have to be updated.- Throws:
IOException
-
unlockTables
Mysql-specific: Unlocks all tables for triggers that have to be updated.- Throws:
IOException
-
getCreateTableCommandPrefix
Returns the database-specific "create table" command prefix. For HANA this is either "create column table" or "create row table", for all other databases it is "create table".- Returns:
- The "create table" command prefix
-
suppressPrimaryKeyOnPartition
-
addTablePartition
public void addTablePartition(DdlBuffer apply, String partitionMode, String partitionColumn) throws IOException- Throws:
IOException
-