Class AlterTableBuilder
java.lang.Object
com.valqueries.automapper.context.schema.AlterTableBuilder
- All Implemented Interfaces:
- IAlterTableBuilder,- IBaseBuilder
- Direct Known Subclasses:
- DryRunAlterTableBuilder
- 
Constructor SummaryConstructorsConstructorDescriptionAlterTableBuilder(org.jooq.CloseableDSLContext jooq, Supplier<org.jooq.AlterTableStep> jooqStepSupplier, String formattedTableName, Database database, SchemaExaminer schemaExaminer, String schema, Token table) 
- 
Method SummaryModifier and TypeMethodDescriptionAdd a column with a specific sql type.addColumnIfNotExists(Token columnName, SqlType<?> columnType) Add a column with a specific sql type.addForeignKey(String constraintName, Token[] columns, Token referencedTable, Token[] referencedColumns) Add a foreign keyAdd an indexaddPrimaryKey(Token firstColumn, Token... columns) Add a primary key.Add a unique constraintchangeColumnType(Token columnName, SqlType<?> newColumnType) Change the type of column to a specific sql type.changeColumnTypeIfExists(Token columnName, SqlType<?> newColumnType) Change the type of column to a specific sql type, if it exists.changePrimaryKey(Token firstColumn, Token... columns) Change the primary key.dropColumn(Token columnName) Drop a column.dropColumnIfExists(Token columnName) Drop a column if it exists.dropForeignKey(String constraintName) Drop a foreign key.Drop an index.Drop a primary key without adding a new one.Drop a primary key if it exists, without adding a new one.dropUnique(String constraintName) Drop a unique constraint.voidexecute()Execute the create/alter table statement(s)getSql()Useful for debuggingrenameColumn(Token oldColumnName, Token newColumnName) Rename a column.renameColumnIfPossible(Token oldColumnName, Token newColumnName) Rename a column if it exists and no column exists with the new name.renameIndex(String oldIndexName, String newIndexName) Rename an indexrenameTable(Token newTableName) Rename a table.renameTableIfPossible(Token newTableName) Rename a table if no table exists with the new name.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.valqueries.automapper.context.schema.IAlterTableBuilderaddColumn, addColumn, addColumn, addColumnIfNotExists, addColumnIfNotExists, addColumnIfNotExists, addForeignKey, addForeignKey, addForeignKey, addIndex, addPrimaryKey, addUnique, changeColumnType, changeColumnType, changeColumnType, changeColumnTypeIfExists, changeColumnTypeIfExists, changeColumnTypeIfExists, changePrimaryKey, dropColumn, dropColumnIfExists, renameColumn, renameColumnIfPossible, renameTable, renameTableIfPossible
- 
Constructor Details- 
AlterTableBuilder
 
- 
- 
Method Details- 
renameTableDescription copied from interface:IAlterTableBuilderRename a table.Note: This is a terminal statement. - Specified by:
- renameTablein interface- IAlterTableBuilder
- Parameters:
- newTableName- the new name of the table
- Returns:
- this builder, but no more chaining makes sense after this statement. Remember to call IBaseBuilder.execute()
 
- 
renameTableIfPossibleDescription copied from interface:IAlterTableBuilderRename a table if no table exists with the new name.Note: This is a terminal statement. - Specified by:
- renameTableIfPossiblein interface- IAlterTableBuilder
- Parameters:
- newTableName- the new name of the table
- Returns:
- this builder, but no more chaining makes sense after this statement. Remember to call IBaseBuilder.execute()
 
- 
addColumnDescription copied from interface:IAlterTableBuilderAdd a column with a specific sql type. Will fail if a column with the same name already exists. If you are adding auto-increment column it will be automatically made the new primary key.- Specified by:
- addColumnin interface- IAlterTableBuilder
- Parameters:
- columnName- the name of the column
- columnType- the type of the column
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
addColumnIfNotExistsDescription copied from interface:IAlterTableBuilderAdd a column with a specific sql type. Does nothing if a column with the same name already exists. If you are adding auto-increment column it will be automatically made the new primary key.- Specified by:
- addColumnIfNotExistsin interface- IAlterTableBuilder
- Parameters:
- columnName- the name of the column
- columnType- the type of the column
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
renameColumnDescription copied from interface:IAlterTableBuilderRename a column.- Specified by:
- renameColumnin interface- IAlterTableBuilder
- Parameters:
- oldColumnName- the old name of the column
- newColumnName- the new name of the column
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
renameColumnIfPossibleDescription copied from interface:IAlterTableBuilderRename a column if it exists and no column exists with the new name.- Specified by:
- renameColumnIfPossiblein interface- IAlterTableBuilder
- Parameters:
- oldColumnName- the old name of the column
- newColumnName- the new name of the column
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
changeColumnTypeDescription copied from interface:IAlterTableBuilderChange the type of column to a specific sql type. Auto-increment is not supported, you will have to drop the column and add a new one.- Specified by:
- changeColumnTypein interface- IAlterTableBuilder
- Parameters:
- columnName- the name of the column
- newColumnType- the new type of the column
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
changeColumnTypeIfExistsDescription copied from interface:IAlterTableBuilderChange the type of column to a specific sql type, if it exists. Auto-increment is not supported, you will have to drop the column and add a new one.- Specified by:
- changeColumnTypeIfExistsin interface- IAlterTableBuilder
- Parameters:
- columnName- the name of the column
- newColumnType- the new type of the column
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
dropColumnDescription copied from interface:IAlterTableBuilderDrop a column. Will fail if the column does not exist.- Specified by:
- dropColumnin interface- IAlterTableBuilder
- Parameters:
- columnName- the name of the column
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
dropColumnIfExistsDescription copied from interface:IAlterTableBuilderDrop a column if it exists.- Specified by:
- dropColumnIfExistsin interface- IAlterTableBuilder
- Parameters:
- columnName- the name of the column
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
addPrimaryKeyDescription copied from interface:IAlterTableBuilderAdd a primary key. If the table already has a primary key, useIAlterTableBuilder.changePrimaryKey(Token, Token...).- Specified by:
- addPrimaryKeyin interface- IAlterTableBuilder
- Parameters:
- firstColumn- the first column of the primary key
- columns- the rest of the columns of the primary key
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
addForeignKeypublic IAlterTableBuilder addForeignKey(String constraintName, Token[] columns, Token referencedTable, Token[] referencedColumns) Description copied from interface:IAlterTableBuilderAdd a foreign key- Specified by:
- addForeignKeyin interface- IAlterTableBuilder
- Parameters:
- constraintName- the name of the foreign key
- columns- the columns of the foreign key
- referencedTable- the table referenced by the foreign key
- referencedColumns- the referenced columns of the foreign key
- Returns:
- foreign key builder used to specify the referenced table and column(s)
 
- 
addUniqueDescription copied from interface:IAlterTableBuilderAdd a unique constraint- Specified by:
- addUniquein interface- IAlterTableBuilder
- Parameters:
- constraintName- the name of the constraint
- firstColumn- the first column of the constraint
- columns- the rest of the columns of the constraint
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
addIndexDescription copied from interface:IAlterTableBuilderAdd an index- Specified by:
- addIndexin interface- IAlterTableBuilder
- Parameters:
- indexName- the name of the index
- firstColumn- the first column of the index
- columns- the rest of the columns of the index
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
changePrimaryKeyDescription copied from interface:IAlterTableBuilderChange the primary key. Works regardless if the table already has a primary key or not.- Specified by:
- changePrimaryKeyin interface- IAlterTableBuilder
- Parameters:
- firstColumn- the first column of the primary key
- columns- the rest of the columns of the primary key
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
renameIndexDescription copied from interface:IAlterTableBuilderRename an index- Specified by:
- renameIndexin interface- IAlterTableBuilder
- Parameters:
- oldIndexName- the old name of the index
- newIndexName- the new name of the index
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
dropPrimaryKeyDescription copied from interface:IAlterTableBuilderDrop a primary key without adding a new one. Consider usingIAlterTableBuilder.changePrimaryKey(String, String...)instead. If you are adding auto-increment column as a new primary key, do not use this method, but useIAlterTableBuilder.changePrimaryKey(String, String...)afterwards.- Specified by:
- dropPrimaryKeyin interface- IAlterTableBuilder
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
dropPrimaryKeyIfExistsDescription copied from interface:IAlterTableBuilderDrop a primary key if it exists, without adding a new one. Consider usingIAlterTableBuilder.changePrimaryKey(String, String...)instead. If you are adding auto-increment column as a new primary key, do not use this method, but useIAlterTableBuilder.changePrimaryKey(String, String...)afterwards.- Specified by:
- dropPrimaryKeyIfExistsin interface- IAlterTableBuilder
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
dropForeignKeyDescription copied from interface:IAlterTableBuilderDrop a foreign key. Will fail if the foreign key does not exist.- Specified by:
- dropForeignKeyin interface- IAlterTableBuilder
- Parameters:
- constraintName- the name of the foreign key
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
dropUniqueDescription copied from interface:IAlterTableBuilderDrop a unique constraint. Will fail if the constraint does not exist.- Specified by:
- dropUniquein interface- IAlterTableBuilder
- Parameters:
- constraintName- the name of the constraint
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
dropIndexDescription copied from interface:IAlterTableBuilderDrop an index. Will fail if the index does not exist.- Specified by:
- dropIndexin interface- IAlterTableBuilder
- Parameters:
- indexName- the name of the index
- Returns:
- this builder, for chaining. Remember to call IBaseBuilder.execute()
 
- 
executepublic void execute()Description copied from interface:IBaseBuilderExecute the create/alter table statement(s)- Specified by:
- executein interface- IBaseBuilder
 
- 
getSqlDescription copied from interface:IBaseBuilderUseful for debugging- Specified by:
- getSqlin interface- IBaseBuilder
- Returns:
- the sql that would be executed by IBaseBuilder.execute()
 
 
-