Class HibernateAlterTableExecutor
- java.lang.Object
-
- com.atlassian.confluence.upgrade.ddl.HibernateAlterTableExecutor
-
- All Implemented Interfaces:
AlterTableExecutor
public class HibernateAlterTableExecutor extends Object implements AlterTableExecutor
Executes all the various database-specific table altering commands.PLEASE READ: Due to CONFDEV-7957 (and until HSQLDB addresses their concurrency issues), any upgrade tasks that composes this executor must be wrapped in a transaction proxy with REQUIRES_NEW propagation.
- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description static intHSQLDB_RELATION_ALREADY_EXISTS_ERRORCODEstatic StringHSQLDB_RELATION_ALREADY_EXISTS_SQLSTATEstatic intMYSQL_RELATION_ALREADY_EXISTS_ERRORCODEstatic StringMYSQL_RELATION_ALREADY_EXISTS_SQLSTATEstatic StringPOSTGRES_RELATION_ALREADY_EXISTS_SQLSTATEstatic intSQLSERVER_INDEX_ALREADY_EXISTS_ERRORCODEstatic intSQLSERVER_RELATION_ALREADY_EXISTS_ERRORCODE
-
Constructor Summary
Constructors Constructor Description HibernateAlterTableExecutor(HibernateDatabaseCapabilities databaseCapabilities, DdlExecutor ddlExecutor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidalterTable(String tableName, List<? extends AlterTableCommand> commands)Perform a set of table altering actions on a given table.AddUniqueConstraintCommandcreateAddUniqueConstraintCommand(String constraintName, String... columnNames)AlterColumnNullabilityCommandcreateAlterColumnNullChoiceCommand(String columnName, String oldDataType, NullChoice nullChoice)DropUniqueConstraintByColumnsCommandcreateDropUniqueConstraintByColumnsCommand(String... columnNames)Drop constraints by column names.DropUniqueConstraintCommandcreateDropUniqueConstraintCommand(String constraintName)List<String>getAlterTableStatements(String tableName, List<? extends AlterTableCommand> commands)
-
-
-
Field Detail
-
POSTGRES_RELATION_ALREADY_EXISTS_SQLSTATE
public static final String POSTGRES_RELATION_ALREADY_EXISTS_SQLSTATE
- See Also:
- Constant Field Values
-
MYSQL_RELATION_ALREADY_EXISTS_SQLSTATE
public static final String MYSQL_RELATION_ALREADY_EXISTS_SQLSTATE
- See Also:
- Constant Field Values
-
MYSQL_RELATION_ALREADY_EXISTS_ERRORCODE
public static final int MYSQL_RELATION_ALREADY_EXISTS_ERRORCODE
- See Also:
- Constant Field Values
-
SQLSERVER_INDEX_ALREADY_EXISTS_ERRORCODE
public static final int SQLSERVER_INDEX_ALREADY_EXISTS_ERRORCODE
- See Also:
- Constant Field Values
-
SQLSERVER_RELATION_ALREADY_EXISTS_ERRORCODE
public static final int SQLSERVER_RELATION_ALREADY_EXISTS_ERRORCODE
- See Also:
- Constant Field Values
-
HSQLDB_RELATION_ALREADY_EXISTS_SQLSTATE
public static final String HSQLDB_RELATION_ALREADY_EXISTS_SQLSTATE
- See Also:
- Constant Field Values
-
HSQLDB_RELATION_ALREADY_EXISTS_ERRORCODE
public static final int HSQLDB_RELATION_ALREADY_EXISTS_ERRORCODE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HibernateAlterTableExecutor
public HibernateAlterTableExecutor(HibernateDatabaseCapabilities databaseCapabilities, DdlExecutor ddlExecutor)
- Since:
- 7.20
-
-
Method Detail
-
createAlterColumnNullChoiceCommand
public AlterColumnNullabilityCommand createAlterColumnNullChoiceCommand(String columnName, String oldDataType, NullChoice nullChoice)
- Specified by:
createAlterColumnNullChoiceCommandin interfaceAlterTableExecutor
-
createAddUniqueConstraintCommand
public AddUniqueConstraintCommand createAddUniqueConstraintCommand(String constraintName, String... columnNames)
- Specified by:
createAddUniqueConstraintCommandin interfaceAlterTableExecutor
-
createDropUniqueConstraintCommand
public DropUniqueConstraintCommand createDropUniqueConstraintCommand(String constraintName)
- Specified by:
createDropUniqueConstraintCommandin interfaceAlterTableExecutor
-
createDropUniqueConstraintByColumnsCommand
public DropUniqueConstraintByColumnsCommand createDropUniqueConstraintByColumnsCommand(String... columnNames)
Description copied from interface:AlterTableExecutorDrop constraints by column names. This operation is presently only supported for Oracle.- Specified by:
createDropUniqueConstraintByColumnsCommandin interfaceAlterTableExecutor- Parameters:
columnNames- The names of the columns that make up the unique constraint
-
alterTable
public void alterTable(String tableName, List<? extends AlterTableCommand> commands)
Description copied from interface:AlterTableExecutorPerform a set of table altering actions on a given table. On some databases such as PostgreSQL this is combined into a single statement automatically. On other databases such as HSQLDB, each alter action is executed as a separate statement.- Specified by:
alterTablein interfaceAlterTableExecutor- Parameters:
tableName- Name of the table to altercommands- A collection of alter table actions to perform
-
getAlterTableStatements
public List<String> getAlterTableStatements(String tableName, List<? extends AlterTableCommand> commands)
- Specified by:
getAlterTableStatementsin interfaceAlterTableExecutor
-
-