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 voiddropTable(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 voidinit()protected booleanisFullTextIndex(IIndex index) mapDefaultValue(Object defaultValue, Column column) protected voidprocessChange(Database currentModel, Database desiredModel, AddColumnChange change, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, PrimaryKeyChange change, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, RemoveColumnChange change, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, RemovePrimaryKeyChange change, StringBuilder ddl) protected voidprocessColumnChange(Table sourceTable, Table targetTable, Column sourceColumn, Column targetColumn, StringBuilder ddl) protected voidprocessTableStructureChanges(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 booleanshouldGeneratePrimaryKeys(Column[] primaryKeyColumns) Determines whether we should generate a primary key constraint for the given primary key columns.protected booleanshouldUseQuotes(String defaultValue, Column column) protected voidwriteColumnAutoIncrementStmt(Table table, Column column, StringBuilder ddl) Prints that the column is an auto increment column.protected voidwriteColumnAutoUpdateStmt(Table table, Column column, StringBuilder ddl) protected voidwriteColumnDefaultValue(Table table, Column column, StringBuilder ddl) Prints the default value of the column.protected voidwriteColumnDefaultValueStmt(Table table, Column column, StringBuilder ddl) Prints the default value stmt part for the column.protected voidwriteExternalForeignKeyDropStmt(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:
mapDefaultValuein interfaceIDdlBuilder- Overrides:
mapDefaultValuein classAbstractDdlBuilder
-
dropTable
Description copied from class:AbstractDdlBuilderOutputs 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:
dropTablein classAbstractDdlBuilderrecreate- TODO
-
writeColumnAutoIncrementStmt
Description copied from class:AbstractDdlBuilderPrints that the column is an auto increment column.- Overrides:
writeColumnAutoIncrementStmtin classAbstractDdlBuilder
-
writeColumnDefaultValueStmt
Description copied from class:AbstractDdlBuilderPrints the default value stmt part for the column.- Overrides:
writeColumnDefaultValueStmtin classAbstractDdlBuilder
-
writeColumnDefaultValue
Description copied from class:AbstractDdlBuilderPrints the default value of the column.- Overrides:
writeColumnDefaultValuein classAbstractDdlBuilder
-
writeColumnAutoUpdateStmt
- Overrides:
writeColumnAutoUpdateStmtin classAbstractDdlBuilder
-
shouldUseQuotes
- Overrides:
shouldUseQuotesin classAbstractDdlBuilder
-
shouldGeneratePrimaryKeys
Description copied from class:AbstractDdlBuilderDetermines whether we should generate a primary key constraint for the given primary key columns.- Overrides:
shouldGeneratePrimaryKeysin classAbstractDdlBuilder- Parameters:
primaryKeyColumns- The pk columns- Returns:
trueif a pk statement should be generated for the columns
-
getSelectLastIdentityValues
Description copied from class:AbstractDdlBuilderGenerates 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:
getSelectLastIdentityValuesin classAbstractDdlBuilder- Parameters:
table- The table- Returns:
- The sql, or
nullif the database does not support this
-
writeExternalForeignKeyDropStmt
protected void writeExternalForeignKeyDropStmt(Table table, ForeignKey foreignKey, StringBuilder ddl) Description copied from class:AbstractDdlBuilderGenerates the statement to drop a foreignkey constraint from the database using an alter table statement.- Overrides:
writeExternalForeignKeyDropStmtin classAbstractDdlBuilder- Parameters:
table- The tableforeignKey- The foreign key
-
isFullTextIndex
- Overrides:
isFullTextIndexin classAbstractDdlBuilder
-
processTableStructureChanges
protected void processTableStructureChanges(Database currentModel, Database desiredModel, Table sourceTable, Table targetTable, List<TableChange> changes, StringBuilder ddl) Description copied from class:AbstractDdlBuilderAllows 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, allAddPrimaryKeyChangechanges are applied via anALTER TABLE ADD CONSTRAINTstatement.- Overrides:
processTableStructureChangesin 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:AbstractDdlBuilderReturns the full SQL type specification (including size and precision/scale) for the given column.- Specified by:
getSqlTypein interfaceIDdlBuilder- Overrides:
getSqlTypein classAbstractDdlBuilder- Parameters:
column- The column- Returns:
- The full SQL type string including the size
-