Package org.jumpmind.db.platform.mysql
Class MySqlDdlBuilder
java.lang.Object
org.jumpmind.db.platform.AbstractDdlBuilder
org.jumpmind.db.platform.mysql.MySqlDdlBuilder
- All Implemented Interfaces:
IDdlBuilder
-
Field Summary
Fields inherited from class org.jumpmind.db.platform.AbstractDdlBuilder
caseSensitive, databaseInfo, databaseName, delimitedIdentifierModeOn, log, scriptModeOn, SIZE_PLACEHOLDER, sqlCommentsOn
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
dropTable
(Table table, StringBuilder ddl, boolean temporary, boolean recreate) Outputs the DDL to drop the table.getSelectLastIdentityValues
(Table table) Generates the SQL for querying the id that was created in the last insertion operation.getSqlType
(Column column) Returns the full SQL type specification (including size and precision/scale) for the given column.protected void
init()
protected boolean
isFullTextIndex
(IIndex index) mapDefaultValue
(Object defaultValue, Column column) protected void
processChange
(Database currentModel, Database desiredModel, AddColumnChange change, StringBuilder ddl) protected void
processChange
(Database currentModel, Database desiredModel, PrimaryKeyChange change, StringBuilder ddl) protected void
processChange
(Database currentModel, Database desiredModel, RemoveColumnChange change, StringBuilder ddl) protected void
processChange
(Database currentModel, Database desiredModel, RemovePrimaryKeyChange change, StringBuilder ddl) protected void
processColumnChange
(Table sourceTable, Table targetTable, Column sourceColumn, Column targetColumn, StringBuilder ddl) protected void
processTableStructureChanges
(Database currentModel, Database desiredModel, Table sourceTable, Table targetTable, List<TableChange> changes, StringBuilder ddl) Allows database-specific implementations to handle changes in a database specific manner.protected boolean
shouldGeneratePrimaryKeys
(Column[] primaryKeyColumns) Determines whether we should generate a primary key constraint for the given primary key columns.protected boolean
shouldUseQuotes
(String defaultValue, Column column) protected void
writeColumnAutoIncrementStmt
(Table table, Column column, StringBuilder ddl) Prints that the column is an auto increment column.protected void
writeColumnAutoUpdateStmt
(Table table, Column column, StringBuilder ddl) protected void
writeColumnDefaultValue
(Table table, Column column, StringBuilder ddl) Prints the default value of the column.protected void
writeColumnDefaultValueStmt
(Table table, Column column, StringBuilder ddl) Prints the default value stmt part for the column.protected void
writeExternalForeignKeyDropStmt
(Table table, ForeignKey foreignKey, StringBuilder ddl) Generates the statement to drop a foreignkey constraint from the database using an alter table statement.Methods inherited from class org.jumpmind.db.platform.AbstractDdlBuilder
addEscapedCharSequence, alterDatabase, alterDatabase, alterTable, areColumnSizesTheSame, areEqual, areMappedTypesTheSame, copy, createBackupTableFor, createExternalForeignKeys, createExternalForeignKeys, createTable, createTable, createTables, createTables, createTemporaryTable, dropExternalForeignKeys, dropTable, dropTables, dropTables, dropTemporaryTable, escapeStringValue, filterChanges, filterColumnSqlType, findCorrespondingForeignKey, findForeignKey, findTable, fixLastIdentityValues, getBackupTableFor, getBareNativeType, getColumnName, getColumnTypeDdl, getConstraintName, getCopyDataColumnMapping, getCopyDataColumnOrderedMapping, getDatabaseInfo, getDefaultValueHelper, getDefinitionForGeneratedColumn, getDeleteSql, getDelimitedIdentifier, getDetectedChanges, getForeignKeyName, getFullyQualifiedIndexNameShorten, getFullyQualifiedTableNameShorten, getGapLimitSize, getIndent, getIndexName, getInsertSql, getNativeDefaultValue, getNativeType, getRealTargetTableFor, getSize, getTableName, getTemporaryTableFor, getTemporaryTableFor, getTriggerDelimiterReplacementCharacters, getUpdateSql, getValueAsString, getValueDateFormat, getValueLocale, getValueNumberFormat, getValueTimeFormat, hasSize, initCteExpression, isAlterDatabase, isCaseSensitive, isDelimitedIdentifierModeOn, isScriptModeOn, isSpecifyIdentityGapLimit, isSqlCommentsOn, isValidDefaultValue, mergeOrRemovePlatformTypes, printComment, printDefaultValue, printEndOfStatement, printIdentifier, printIndent, println, println, printlnIdentifier, printStartOfEmbeddedStatement, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChanges, processChanges, processTableStructureChanges, processTableStructureChanges, renameTable, replaceDelimiterWithEscapeCharacters, restoreTableFromBackup, setCaseSensitive, setDelimitedIdentifierModeOn, setIndent, setScriptModeOn, setSqlCommentsOn, setTriggerDelimiterReplacementCharacters, setValueDateFormat, setValueLocale, setValueNumberFormat, setValueTimeFormat, shortenName, writeAlterColumnDataTypeToBigInt, writeCascadeAttributesForForeignKey, writeCascadeAttributesForForeignKeyDelete, writeCascadeAttributesForForeignKeyUpdate, writeCastExpression, writeColumn, writeColumnEmbeddedPrimaryKey, writeColumnNotNullableStmt, writeColumnNullableStmt, writeColumns, writeColumnType, writeColumnTypeDefaultRequired, writeColumnUniqueStmt, writeCopyDataStatement, writeCopyDataStatement, writeEmbeddedForeignKeysStmt, writeEmbeddedIndexCreateStmt, writeEmbeddedIndicesStmt, writeEmbeddedPrimaryKeysStmt, writeExternalForeignKeyCreateStmt, writeExternalIndexCreate, writeExternalIndexCreateStmt, writeExternalIndexDropStmt, writeExternalIndicesCreateStmt, writeExternalPrimaryKeysCreateStmt, writeFixLastIdentityValues, writeForeignReferences, writeGeneratedColumn, writeIdentityGapLimit, writeLocalReferences, writePrimaryKeyStmt, writeTableAlterStmt, writeTableComment, writeTableCreateOpeningStmt, writeTableCreationStmt, writeTableCreationStmtEnding
-
Constructor Details
-
MySqlDdlBuilder
-
MySqlDdlBuilder
public MySqlDdlBuilder()
-
-
Method Details
-
init
protected void init() -
mapDefaultValue
- Specified by:
mapDefaultValue
in interfaceIDdlBuilder
- Overrides:
mapDefaultValue
in classAbstractDdlBuilder
-
dropTable
Description copied from class:AbstractDdlBuilder
Outputs the DDL to drop the table. Note that this method does not drop foreign keys to this table. Use#dropTable(Database, Table)
if you want that.- Overrides:
dropTable
in classAbstractDdlBuilder
recreate
- TODO
-
writeColumnAutoIncrementStmt
Description copied from class:AbstractDdlBuilder
Prints that the column is an auto increment column.- Overrides:
writeColumnAutoIncrementStmt
in classAbstractDdlBuilder
-
writeColumnDefaultValueStmt
Description copied from class:AbstractDdlBuilder
Prints the default value stmt part for the column.- Overrides:
writeColumnDefaultValueStmt
in classAbstractDdlBuilder
-
writeColumnDefaultValue
Description copied from class:AbstractDdlBuilder
Prints the default value of the column.- Overrides:
writeColumnDefaultValue
in classAbstractDdlBuilder
-
writeColumnAutoUpdateStmt
- Overrides:
writeColumnAutoUpdateStmt
in classAbstractDdlBuilder
-
shouldUseQuotes
- Overrides:
shouldUseQuotes
in classAbstractDdlBuilder
-
shouldGeneratePrimaryKeys
Description copied from class:AbstractDdlBuilder
Determines whether we should generate a primary key constraint for the given primary key columns.- Overrides:
shouldGeneratePrimaryKeys
in classAbstractDdlBuilder
- Parameters:
primaryKeyColumns
- The pk columns- Returns:
true
if a pk statement should be generated for the columns
-
getSelectLastIdentityValues
Description copied from class:AbstractDdlBuilder
Generates the SQL for querying the id that was created in the last insertion operation. This is obviously only useful for pk fields that are auto-incrementing. A database that does not support this, will returnnull
.- Overrides:
getSelectLastIdentityValues
in classAbstractDdlBuilder
- Parameters:
table
- The table- Returns:
- The sql, or
null
if the database does not support this
-
writeExternalForeignKeyDropStmt
protected void writeExternalForeignKeyDropStmt(Table table, ForeignKey foreignKey, StringBuilder ddl) Description copied from class:AbstractDdlBuilder
Generates the statement to drop a foreignkey constraint from the database using an alter table statement.- Overrides:
writeExternalForeignKeyDropStmt
in classAbstractDdlBuilder
- Parameters:
table
- The tableforeignKey
- The foreign key
-
isFullTextIndex
- Overrides:
isFullTextIndex
in classAbstractDdlBuilder
-
processTableStructureChanges
protected void processTableStructureChanges(Database currentModel, Database desiredModel, Table sourceTable, Table targetTable, List<TableChange> changes, StringBuilder ddl) Description copied from class:AbstractDdlBuilder
Allows database-specific implementations to handle changes in a database specific manner. Any handled change should be applied to the given current model (which is a copy of the real original model) and be removed from the list of changes.
In the default implementation, allAddPrimaryKeyChange
changes are applied via anALTER TABLE ADD CONSTRAINT
statement.- Overrides:
processTableStructureChanges
in classAbstractDdlBuilder
- Parameters:
currentModel
- The current database schemadesiredModel
- The desired database schemasourceTable
- The original tabletargetTable
- The desired tablechanges
- The change objects for the target table
-
processChange
protected void processChange(Database currentModel, Database desiredModel, AddColumnChange change, StringBuilder ddl) -
processChange
protected void processChange(Database currentModel, Database desiredModel, RemoveColumnChange change, StringBuilder ddl) -
processChange
protected void processChange(Database currentModel, Database desiredModel, RemovePrimaryKeyChange change, StringBuilder ddl) -
processChange
protected void processChange(Database currentModel, Database desiredModel, PrimaryKeyChange change, StringBuilder ddl) -
processColumnChange
protected void processColumnChange(Table sourceTable, Table targetTable, Column sourceColumn, Column targetColumn, StringBuilder ddl) -
getSqlType
Description copied from class:AbstractDdlBuilder
Returns the full SQL type specification (including size and precision/scale) for the given column.- Specified by:
getSqlType
in interfaceIDdlBuilder
- Overrides:
getSqlType
in classAbstractDdlBuilder
- Parameters:
column
- The column- Returns:
- The full SQL type string including the size
-