Interface IAlterTableBuilder
- All Superinterfaces:
IBaseBuilder
- All Known Implementing Classes:
AlterTableBuilder,DryRunAlterTableBuilder
-
Method Summary
Modifier and TypeMethodDescriptionAdd a column with a specific sql type.default IAlterTableBuilderAdd a column with a type deduced from a java class.default IAlterTableBuilderAdd a column with a specific sql type.default IAlterTableBuilderAdd a column with a type deduced from a java class.addColumnIfNotExists(Token columnName, SqlType<?> columnType) Add a column with a specific sql type.default IAlterTableBuilderaddColumnIfNotExists(Token columnName, Class<?> columnType) Add a column with a type deduced from a java class.default IAlterTableBuilderaddColumnIfNotExists(String columnName, SqlType<?> columnType) Add a column with a specific sql type.default IAlterTableBuilderaddColumnIfNotExists(String columnName, Class<?> columnType) Add a column with a type deduced from a java class.addForeignKey(String constraintName, Token[] columns, Token referencedTable, Token[] referencedColumns) Add a foreign keydefault IForeignKeyBuilder<IAlterTableBuilder>addForeignKey(String constraintName, Token firstColumn, Token... columns) Add a foreign keydefault IAlterTableBuilderaddForeignKey(String constraintName, String[] columns, String referencedTable, String[] referencedColumns) Add a foreign keydefault IForeignKeyBuilder<IAlterTableBuilder>addForeignKey(String constraintName, String firstColumn, String... columns) Add a foreign keyAdd an indexdefault IAlterTableBuilderAdd an indexaddPrimaryKey(Token firstColumn, Token... columns) Deprecated.default IAlterTableBuilderaddPrimaryKey(String firstColumn, String... columns) Deprecated.because it requires the table to not have a primary key, which is not allowed on MySQL ifsql_require_primary_keyis set.Add a unique constraintdefault IAlterTableBuilderAdd a unique constraintchangeColumnType(Token columnName, SqlType<?> newColumnType) Change the type of column to a specific sql type.default IAlterTableBuilderchangeColumnType(Token columnName, Class<?> newColumnType) Change the type of column to a type deduced from a java class.default IAlterTableBuilderchangeColumnType(String columnName, SqlType<?> newColumnType) Change the type of column to a specific sql type.default IAlterTableBuilderchangeColumnType(String columnName, Class<?> newColumnType) Change the type of column to a type deduced from a java class.changeColumnTypeIfExists(Token columnName, SqlType<?> newColumnType) Change the type of column to a specific sql type, if it exists.default IAlterTableBuilderchangeColumnTypeIfExists(Token columnName, Class<?> newColumnType) Change the type of column to a type deduced from a java class, if it exists.default IAlterTableBuilderchangeColumnTypeIfExists(String columnName, SqlType<?> newColumnType) Change the type of column to a specific sql type, if it exists.default IAlterTableBuilderchangeColumnTypeIfExists(String columnName, Class<?> newColumnType) Change the type of column to a type deduced from a java class, if it exists.changePrimaryKey(Token firstColumn, Token... columns) Change the primary key.default IAlterTableBuilderchangePrimaryKey(String firstColumn, String... columns) Change the primary key.dropColumn(Token columnName) Drop a column.default IAlterTableBuilderdropColumn(String columnName) Drop a column.dropColumnIfExists(Token columnName) Drop a column if it exists.default IAlterTableBuilderdropColumnIfExists(String columnName) Drop a column if it exists.dropForeignKey(String constraintName) Drop a foreign key.Drop an index.Deprecated.because it will fail on MySQL ifsql_require_primary_keyis set.Deprecated.because it will fail on MySQL ifsql_require_primary_keyis set.dropUnique(String constraintName) Drop a unique constraint.renameColumn(Token oldColumnName, Token newColumnName) Rename a column.default IAlterTableBuilderrenameColumn(String oldColumnName, String newColumnName) Rename a column.renameColumnIfPossible(Token oldColumnName, Token newColumnName) Rename a column if it exists and no column exists with the new name.default IAlterTableBuilderrenameColumnIfPossible(String oldColumnName, String 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.default IBaseBuilderrenameTable(String newTableName) Rename a table.renameTableIfPossible(Token newTableName) Rename a table if no table exists with the new name.default IBaseBuilderrenameTableIfPossible(String newTableName) Rename a table if no table exists with the new name.Methods inherited from interface com.valqueries.automapper.context.schema.IBaseBuilder
execute, getSql
-
Method Details
-
renameTable
Rename a table.Note: This is a terminal statement.
Note: to specify non-standard table names, use
renameTable(Token)withToken.literal(String)- Parameters:
newTableName- the new name of the table, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb- Returns:
- this builder, but no more chaining makes sense after this statement. Remember to call
IBaseBuilder.execute()
-
renameTable
Rename a table.Note: This is a terminal statement.
- 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()
-
renameTableIfPossible
Rename a table if no table exists with the new name.Note: This is a terminal statement.
Note: to specify non-standard table names, use
renameTableIfPossible(Token)withToken.literal(String)- Parameters:
newTableName- the new name of the table, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb- Returns:
- this builder, but no more chaining makes sense after this statement. Remember to call
IBaseBuilder.execute()
-
renameTableIfPossible
Rename a table if no table exists with the new name.Note: This is a terminal statement.
- 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()
-
addColumn
Add 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.Note: to specify non-standard column names, use
addColumn(Token, SqlType)withToken.literal(String)- Parameters:
columnName- the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbcolumnType- the type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addColumn
Add 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.- Parameters:
columnName- the name of the columncolumnType- the type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addColumn
Add a column with a type deduced from a java class. Will fail if a column with the same name already exists.Note: to specify non-standard column names, use
addColumn(Token, Class)withToken.literal(String)- Parameters:
columnName- the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbcolumnType- the type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addColumn
Add a column with a type deduced from a java class. Will fail if a column with the same name already exists.- Parameters:
columnName- the name of the columncolumnType- the type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addColumnIfNotExists
@CheckReturnValue default IAlterTableBuilder addColumnIfNotExists(String columnName, SqlType<?> columnType) Add 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.Note: to specify non-standard column names, use
addColumnIfNotExists(Token, SqlType)withToken.literal(String)- Parameters:
columnName- the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbcolumnType- the type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addColumnIfNotExists
Add 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.- Parameters:
columnName- the name of the columncolumnType- the type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addColumnIfNotExists
@CheckReturnValue default IAlterTableBuilder addColumnIfNotExists(String columnName, Class<?> columnType) Add a column with a type deduced from a java class. Does nothing if a column with the same name already exists.Note: to specify non-standard column names, use
addColumnIfNotExists(Token, Class)withToken.literal(String)- Parameters:
columnName- the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbcolumnType- the type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addColumnIfNotExists
@CheckReturnValue default IAlterTableBuilder addColumnIfNotExists(Token columnName, Class<?> columnType) Add a column with a type deduced from a java class. Does nothing if a column with the same name already exists.- Parameters:
columnName- the name of the columncolumnType- the type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
renameColumn
@CheckReturnValue default IAlterTableBuilder renameColumn(String oldColumnName, String newColumnName) Rename a column.Note: to specify non-standard column names, use
renameColumn(Token, Token)withToken.literal(String)- Parameters:
oldColumnName- the old name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbnewColumnName- the new name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
renameColumn
Rename a column.- Parameters:
oldColumnName- the old name of the columnnewColumnName- the new name of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
renameColumnIfPossible
@CheckReturnValue default IAlterTableBuilder renameColumnIfPossible(String oldColumnName, String newColumnName) Rename a column if it exists and no column exists with the new name.Note: to specify non-standard column names, use
renameColumn(Token, Token)withToken.literal(String)- Parameters:
oldColumnName- the old name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbnewColumnName- the new name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
renameColumnIfPossible
@CheckReturnValue IAlterTableBuilder renameColumnIfPossible(Token oldColumnName, Token newColumnName) Rename a column if it exists and no column exists with the new name.- Parameters:
oldColumnName- the old name of the columnnewColumnName- the new name of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
changeColumnType
@CheckReturnValue default IAlterTableBuilder changeColumnType(String columnName, SqlType<?> newColumnType) Change the type of column to a specific sql type.Note: to specify non-standard column names, use
changeColumnType(Token, SqlType)withToken.literal(String)- Parameters:
columnName- the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbnewColumnType- the new type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
changeColumnType
Change 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.- Parameters:
columnName- the name of the columnnewColumnType- the new type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
changeColumnType
@CheckReturnValue default IAlterTableBuilder changeColumnType(String columnName, Class<?> newColumnType) Change the type of column to a type deduced from a java class.Note: to specify non-standard column names, use
changeColumnType(Token, Class)withToken.literal(String)- Parameters:
columnName- the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbnewColumnType- the new type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
changeColumnType
@CheckReturnValue default IAlterTableBuilder changeColumnType(Token columnName, Class<?> newColumnType) Change the type of column to a type deduced from a java class.- Parameters:
columnName- the name of the columnnewColumnType- the new type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
changeColumnTypeIfExists
@CheckReturnValue default IAlterTableBuilder changeColumnTypeIfExists(String columnName, SqlType<?> newColumnType) Change the type of column to a specific sql type, if it exists.Note: to specify non-standard column names, use
changeColumnTypeIfExists(Token, SqlType)withToken.literal(String)- Parameters:
columnName- the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbnewColumnType- the new type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
changeColumnTypeIfExists
@CheckReturnValue IAlterTableBuilder changeColumnTypeIfExists(Token columnName, SqlType<?> newColumnType) Change 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.- Parameters:
columnName- the name of the columnnewColumnType- the new type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
changeColumnTypeIfExists
@CheckReturnValue default IAlterTableBuilder changeColumnTypeIfExists(String columnName, Class<?> newColumnType) Change the type of column to a type deduced from a java class, if it exists.Note: to specify non-standard column names, use
changeColumnTypeIfExists(Token, Class)withToken.literal(String)- Parameters:
columnName- the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbnewColumnType- the new type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
changeColumnTypeIfExists
@CheckReturnValue default IAlterTableBuilder changeColumnTypeIfExists(Token columnName, Class<?> newColumnType) Change the type of column to a type deduced from a java class, if it exists.- Parameters:
columnName- the name of the columnnewColumnType- the new type of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
dropColumn
Drop a column. Will fail if the column does not exist.Note: to specify non-standard column names, use
dropColumn(Token)withToken.literal(String)- Parameters:
columnName- the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
dropColumn
Drop a column. Will fail if the column does not exist.- Parameters:
columnName- the name of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
dropColumnIfExists
Drop a column if it exists.Note: to specify non-standard column names, use
dropColumnIfExists(Token)withToken.literal(String)- Parameters:
columnName- the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
dropColumnIfExists
Drop a column if it exists.- Parameters:
columnName- the name of the column- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addPrimaryKey
@Deprecated @CheckReturnValue default IAlterTableBuilder addPrimaryKey(String firstColumn, String... columns) Deprecated.because it requires the table to not have a primary key, which is not allowed on MySQL ifsql_require_primary_keyis set.Add a primary key. If the table already has a primary key, usechangePrimaryKey(String, String...).Note: to specify non-standard column names, use
addPrimaryKey(Token, Token...)withToken.literal(String)- Parameters:
firstColumn- the first column of the primary key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbcolumns- the rest of the columns of the primary key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addPrimaryKey
Deprecated.because it requires the table to not have a primary key, which is not allowed on MySQL ifsql_require_primary_keyis set.Add a primary key. If the table already has a primary key, usechangePrimaryKey(Token, Token...).- Parameters:
firstColumn- the first column of the primary keycolumns- the rest of the columns of the primary key- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addForeignKey
@CheckReturnValue default IForeignKeyBuilder<IAlterTableBuilder> addForeignKey(String constraintName, String firstColumn, String... columns) Add a foreign keyNote: to specify non-standard column names, use
addForeignKey(String, Token, Token...)withToken.literal(String)- Parameters:
constraintName- the name of the foreign keyfirstColumn- the first column of the foreign key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbcolumns- the rest of the columns of the foreign key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- foreign key builder used to specify the referenced table and column(s)
-
addForeignKey
@CheckReturnValue default IForeignKeyBuilder<IAlterTableBuilder> addForeignKey(String constraintName, Token firstColumn, Token... columns) Add a foreign key- Parameters:
constraintName- the name of the foreign keyfirstColumn- the first column of the foreign keycolumns- the rest of the columns of the foreign key- Returns:
- foreign key builder used to specify the referenced table and column(s)
-
addForeignKey
@CheckReturnValue default IAlterTableBuilder addForeignKey(String constraintName, String[] columns, String referencedTable, String[] referencedColumns) Add a foreign keyNote: to specify non-standard column names, use
addForeignKey(String, Token, Token...)withToken.literal(String)- Parameters:
constraintName- the name of the foreign keycolumns- the columns of the foreign key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbreferencedTable- the table referenced by the foreign key, will be tokenized, for example "myTable" will reference table "my_table" for MariaDbreferencedColumns- the referenced columns of the foreign key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- foreign key builder used to specify the referenced table and column(s)
-
addForeignKey
@CheckReturnValue IAlterTableBuilder addForeignKey(String constraintName, Token[] columns, Token referencedTable, Token[] referencedColumns) Add a foreign key- Parameters:
constraintName- the name of the foreign keycolumns- the columns of the foreign keyreferencedTable- the table referenced by the foreign keyreferencedColumns- the referenced columns of the foreign key- Returns:
- foreign key builder used to specify the referenced table and column(s)
-
addUnique
@CheckReturnValue default IAlterTableBuilder addUnique(String constraintName, String firstColumn, String... columns) Add a unique constraintNote: to specify non-standard column names, use
addUnique(String, Token, Token...)withToken.literal(String)- Parameters:
constraintName- the name of the constraintfirstColumn- the first column of the constraint, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbcolumns- the rest of the columns of the constraint, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addUnique
@CheckReturnValue IAlterTableBuilder addUnique(String constraintName, Token firstColumn, Token... columns) Add a unique constraint- Parameters:
constraintName- the name of the constraintfirstColumn- the first column of the constraintcolumns- the rest of the columns of the constraint- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addIndex
@CheckReturnValue IAlterTableBuilder addIndex(String indexName, Token firstColumn, Token... columns) Add an index- Parameters:
indexName- the name of the indexfirstColumn- the first column of the indexcolumns- the rest of the columns of the index- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
addIndex
@CheckReturnValue default IAlterTableBuilder addIndex(String indexName, String firstColumn, String... columns) Add an indexNote: to specify non-standard column names, use
addIndex(String, Token, Token...)withToken.literal(String)- Parameters:
indexName- the name of the indexfirstColumn- the first column of the index, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbcolumns- the rest of the columns of the index, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
changePrimaryKey
Change the primary key. Works regardless if the table already has a primary key or not.Note: to specify non-standard column names, use
changePrimaryKey(Token, Token...)withToken.literal(String)- Parameters:
firstColumn- the first column of the primary key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDbcolumns- the rest of the columns of the primary key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
changePrimaryKey
Change the primary key. Works regardless if the table already has a primary key or not.- Parameters:
firstColumn- the first column of the primary keycolumns- the rest of the columns of the primary key- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
renameIndex
Rename an index- Parameters:
oldIndexName- the old name of the indexnewIndexName- the new name of the index- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
dropPrimaryKey
Deprecated.because it will fail on MySQL ifsql_require_primary_keyis set.Drop a primary key without adding a new one. Consider usingchangePrimaryKey(String, String...)instead. If you are adding auto-increment column as a new primary key, do not use this method, but usechangePrimaryKey(String, String...)afterwards.- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
dropPrimaryKeyIfExists
Deprecated.because it will fail on MySQL ifsql_require_primary_keyis set.Drop a primary key if it exists, without adding a new one. Consider usingchangePrimaryKey(String, String...)instead. If you are adding auto-increment column as a new primary key, do not use this method, but usechangePrimaryKey(String, String...)afterwards.- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
dropForeignKey
Drop a foreign key. Will fail if the foreign key does not exist.- Parameters:
constraintName- the name of the foreign key- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
dropUnique
Drop a unique constraint. Will fail if the constraint does not exist.- Parameters:
constraintName- the name of the constraint- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
dropIndex
Drop an index. Will fail if the index does not exist.- Parameters:
indexName- the name of the index- Returns:
- this builder, for chaining. Remember to call
IBaseBuilder.execute()
-
sql_require_primary_keyis set.