Search in sources :

Example 1 with AddPrimaryKeyStatement

use of liquibase.statement.core.AddPrimaryKeyStatement in project liquibase by liquibase.

the class AddPrimaryKeyChange method generateStatements.

@Override
public SqlStatement[] generateStatements(Database database) {
    boolean shouldValidate = true;
    if (getValidate() != null) {
        shouldValidate = getValidate();
    }
    AddPrimaryKeyStatement statement = new AddPrimaryKeyStatement(getCatalogName(), getSchemaName(), getTableName(), ColumnConfig.arrayFromNames(getColumnNames()), getConstraintName());
    statement.setTablespace(getTablespace());
    statement.setClustered(getClustered());
    statement.setForIndexName(getForIndexName());
    statement.setForIndexSchemaName(getForIndexSchemaName());
    statement.setForIndexCatalogName(getForIndexCatalogName());
    statement.setShouldValidate(shouldValidate);
    if (database instanceof DB2Database) {
        return new SqlStatement[] { statement, new ReorganizeTableStatement(getCatalogName(), getSchemaName(), getTableName()) };
    }
    return new SqlStatement[] { statement };
}
Also used : DB2Database(liquibase.database.core.DB2Database) SqlStatement(liquibase.statement.SqlStatement) AddPrimaryKeyStatement(liquibase.statement.core.AddPrimaryKeyStatement) ReorganizeTableStatement(liquibase.statement.core.ReorganizeTableStatement)

Aggregations

DB2Database (liquibase.database.core.DB2Database)1 SqlStatement (liquibase.statement.SqlStatement)1 AddPrimaryKeyStatement (liquibase.statement.core.AddPrimaryKeyStatement)1 ReorganizeTableStatement (liquibase.statement.core.ReorganizeTableStatement)1