use of liquibase.statement.NotNullConstraint in project liquibase by liquibase.
the class RenameColumnExecuteTest method setupStatements.
@Override
protected List<? extends SqlStatement> setupStatements(Database database) {
ArrayList<CreateTableStatement> statements = new ArrayList<CreateTableStatement>();
CreateTableStatement table = new CreateTableStatement(null, null, TABLE_NAME);
if (database instanceof MySQLDatabase) {
table.addPrimaryKeyColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, "pk_", null);
} else {
table.addColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[] { new NotNullConstraint() });
}
table.addColumn(COLUMN_NAME, DataTypeFactory.getInstance().fromDescription("int", database));
statements.add(table);
if (database.supportsSchemas()) {
table = new CreateTableStatement(DatabaseTestContext.ALT_CATALOG, DatabaseTestContext.ALT_SCHEMA, TABLE_NAME);
table.addColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[] { new NotNullConstraint() });
statements.add(table);
}
return statements;
}
use of liquibase.statement.NotNullConstraint in project liquibase by liquibase.
the class CreateDatabaseChangeLogLockTableGenerator method generateSql.
@Override
public Sql[] generateSql(CreateDatabaseChangeLogLockTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String charTypeName = getCharTypeName(database);
String dateTimeTypeString = getDateTimeTypeString(database);
CreateTableStatement createTableStatement = new CreateTableStatement(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogLockTableName()).setTablespace(database.getLiquibaseTablespaceName()).addPrimaryKeyColumn("ID", DataTypeFactory.getInstance().fromDescription("int", database), null, null, null, new NotNullConstraint()).addColumn("LOCKED", DataTypeFactory.getInstance().fromDescription("boolean", database), null, null, new NotNullConstraint()).addColumn("LOCKGRANTED", DataTypeFactory.getInstance().fromDescription(dateTimeTypeString, database)).addColumn("LOCKEDBY", DataTypeFactory.getInstance().fromDescription(charTypeName + "(255)", database));
return SqlGeneratorFactory.getInstance().generateSql(createTableStatement, database);
}
use of liquibase.statement.NotNullConstraint in project liquibase by liquibase.
the class AddUniqueConstraintExecutorTest method setupStatements.
@Override
protected List<? extends SqlStatement> setupStatements(Database database) {
List<CreateTableStatement> statements = new ArrayList<CreateTableStatement>();
CreateTableStatement table = new CreateTableStatement(null, null, TABLE_NAME);
table.addColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[] { new NotNullConstraint() }).addColumn(COLUMN_NAME, DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[] { new NotNullConstraint() });
statements.add(table);
if (database.supportsSchemas()) {
table = new CreateTableStatement(DatabaseTestContext.ALT_CATALOG, DatabaseTestContext.ALT_SCHEMA, TABLE_NAME);
table.addColumn("id", DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[] { new NotNullConstraint() }).addColumn(COLUMN_NAME, DataTypeFactory.getInstance().fromDescription("int", database), null, new ColumnConstraint[] { new NotNullConstraint() });
statements.add(table);
}
return statements;
}
Aggregations