use of liquibase.statement.core.CreateTableStatement 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.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithSQLiteDatabase.
@Test
public void testAutoIncrementStartWithSQLiteDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof SQLiteDatabase) {
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 SQLlite
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT AUTOINCREMENT)", generatedSql[0].toSql());
}
}
}
use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithIncrementBySybaseDatabase.
@Test
public void testAutoIncrementStartWithIncrementBySybaseDatabase() 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), BigInteger.TEN));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
// start with and increment by not supported by Sybase
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT IDENTITY NULL)", generatedSql[0].toSql());
}
}
}
use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementGenerationTypeOracleDatabase.
@Test
public void testAutoIncrementGenerationTypeOracleDatabase() {
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);
AutoIncrementConstraint autoIncrementConstraint = new AutoIncrementConstraint(COLUMN_NAME1);
autoIncrementConstraint.setGenerationType("ALWAYS");
// ignore when ALWAYS
autoIncrementConstraint.setDefaultOnNull(true);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("SMALLINT{autoIncrement:true}", database), autoIncrementConstraint);
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE CATALOG_NAME.TABLE_NAME (COLUMN1_NAME NUMBER(5) GENERATED ALWAYS AS IDENTITY)", generatedSql[0].toSql());
}
}
}
use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithIncrementByOracleDatabase.
@Test
public void testAutoIncrementStartWithIncrementByOracleDatabase() {
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, BigInteger.ZERO, BigInteger.TEN));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE CATALOG_NAME.TABLE_NAME (COLUMN1_NAME NUMBER(5) GENERATED BY DEFAULT AS IDENTITY (START WITH 0, INCREMENT BY 10))", generatedSql[0].toSql());
}
}
}
Aggregations