use of liquibase.database.Database in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithPostgresDatabase.
@Test
public void testAutoIncrementStartWithPostgresDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof PostgresDatabase) {
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("BIGINT{autoIncrement:true}", database), new AutoIncrementConstraint(COLUMN_NAME1, BigInteger.ZERO, null));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
// start with supported over generated sequence
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGSERIAL)", generatedSql[0].toSql());
}
}
}
use of liquibase.database.Database in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithSybaseDatabase.
@Test
public void testAutoIncrementStartWithSybaseDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof SybaseDatabase) {
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("BIGINT{autoIncrement:true}", database), new AutoIncrementConstraint(COLUMN_NAME1, BigInteger.valueOf(2), null));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
// start with not supported by Sybase
assertEquals("CREATE TABLE [SCHEMA_NAME].[TABLE_NAME] ([COLUMN1_NAME] BIGINT IDENTITY NULL)", generatedSql[0].toSql());
}
}
}
use of liquibase.database.Database in project liquibase by liquibase.
the class CreateTableGeneratorTest method testWithColumnWithDefaultValue.
@Test
public void testWithColumnWithDefaultValue() {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof OracleDatabase) {
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("java.sql.Types.TIMESTAMP", database), new ColumnConfig().setDefaultValue("null").getDefaultValueObject());
if (shouldBeImplementation(database)) {
assertEquals("CREATE TABLE CATALOG_NAME.TABLE_NAME (COLUMN1_NAME TIMESTAMP DEFAULT null)", this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
}
}
}
use of liquibase.database.Database in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithIncrementByH2Database.
@Test
public void testAutoIncrementStartWithIncrementByH2Database() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof H2Database) {
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("BIGINT{autoIncrement:true}", database), new AutoIncrementConstraint(COLUMN_NAME1, BigInteger.ZERO, BigInteger.TEN));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT AUTO_INCREMENT (0, 10))", generatedSql[0].toSql());
}
}
}
use of liquibase.database.Database in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementMSSQLDatabase.
@Test
public void testAutoIncrementMSSQLDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof MSSQLDatabase) {
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("BIGINT{autoIncrement:true}", database), new ColumnConstraint[] { new AutoIncrementConstraint(COLUMN_NAME1), new NotNullConstraint(COLUMN_NAME1) });
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("Error on " + database, "CREATE TABLE [CATALOG_NAME].[SCHEMA_NAME].[TABLE_NAME] ([COLUMN1_NAME] [bigint] IDENTITY (1, 1) NOT NULL)", generatedSql[0].toSql());
}
}
}
Aggregations