use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithIncrementByMSSQLDatabase.
@Test
public void testAutoIncrementStartWithIncrementByMSSQLDatabase() 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, BigInteger.ZERO, BigInteger.TEN), new NotNullConstraint(COLUMN_NAME1) });
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE CATALOG_NAME.SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME bigint IDENTITY (0, 10) NOT NULL)", generatedSql[0].toSql());
}
}
}
use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithMSSQLDatabase.
@Test
public void testAutoIncrementStartWithMSSQLDatabase() 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, BigInteger.ZERO, null), new NotNullConstraint(COLUMN_NAME1) });
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE CATALOG_NAME.SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME bigint IDENTITY (0, 1) " + "NOT NULL)", generatedSql[0].toSql());
}
}
}
use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithIncrementByHsqlDatabase.
@Test
public void testAutoIncrementStartWithIncrementByHsqlDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof HsqlDatabase) {
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.ONE, BigInteger.TEN));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 10))", generatedSql[0].toSql());
}
}
}
use of liquibase.statement.core.CreateTableStatement in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithIncrementBySQLiteDatabase.
@Test
public void testAutoIncrementStartWithIncrementBySQLiteDatabase() 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), BigInteger.TEN));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
// start with and increment by not supported by SQLite
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 testAutoIncrementDerbyDatabase.
@Test
public void testAutoIncrementDerbyDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof DerbyDatabase) {
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 GENERATED BY DEFAULT AS IDENTITY)", generatedSql[0].toSql());
}
}
}
Aggregations