use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testWithDeferredPKs.
@Test
public void testWithDeferredPKs() {
for (Database database : TestContext.getInstance().getAllDatabases()) {
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("int", database), new PrimaryKeyConstraint().addColumns(COLUMN_NAME1).setDeferrable(true).setInitiallyDeferred(true));
if (database.supportsInitiallyDeferrableColumns()) {
assertTrue(this.generatorUnderTest.generateSql(statement, database, null)[0].toSql().contains("DEFERRABLE"));
} else {
assertFalse(this.generatorUnderTest.generateSql(statement, database, null)[0].toSql().contains("DEFERRABLE"));
}
}
}
use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementH2Database.
@Test
public void testAutoIncrementH2Database() 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));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT GENERATED BY DEFAULT AS IDENTITY)", generatedSql[0].toSql());
}
}
}
use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementMySQLDatabase.
@Test
public void testAutoIncrementMySQLDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof MySQLDatabase) {
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));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE CATALOG_NAME.TABLE_NAME (COLUMN1_NAME BIGINT AUTO_INCREMENT NULL)", generatedSql[0].toSql());
}
}
}
use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementOracleDatabase.
@Test
public void testAutoIncrementOracleDatabase() {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof OracleDatabase) {
MockDatabaseConnection conn = new MockDatabaseConnection();
database.setConnection(conn);
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("SMALLINT{autoIncrement:true}", database), new AutoIncrementConstraint(COLUMN_NAME1));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE CATALOG_NAME.TABLE_NAME (COLUMN1_NAME NUMBER(5) GENERATED BY DEFAULT AS IDENTITY)", generatedSql[0].toSql());
}
}
}
use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testWithColumnSpecificIntType.
@Test
public void testWithColumnSpecificIntType() {
for (Database database : TestContext.getInstance().getAllDatabases()) {
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("int(11) unsigned", database));
}
}
Aggregations