Search in sources :

Example 6 with HsqlDatabase

use of liquibase.database.core.HsqlDatabase in project liquibase by liquibase.

the class TagDatabaseGeneratorTest method testHsql.

@Test
public void testHsql() throws Exception {
    TagDatabaseStatement statement = new TagDatabaseStatement("v1.0");
    Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(statement, new HsqlDatabase());
    assertEquals(1, sql.length);
    assertEquals("UPDATE DATABASECHANGELOG " + "SET TAG = 'v1.0' " + "WHERE DATEEXECUTED = (" + "SELECT MAX(DATEEXECUTED) " + "FROM DATABASECHANGELOG" + ")", sql[0].toSql());
}
Also used : HsqlDatabase(liquibase.database.core.HsqlDatabase) TagDatabaseStatement(liquibase.statement.core.TagDatabaseStatement) Sql(liquibase.sql.Sql) Test(org.junit.Test)

Example 7 with HsqlDatabase

use of liquibase.database.core.HsqlDatabase 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());
        }
    }
}
Also used : HsqlDatabase(liquibase.database.core.HsqlDatabase) AutoIncrementConstraint(liquibase.statement.AutoIncrementConstraint) CreateTableStatement(liquibase.statement.core.CreateTableStatement) SQLiteDatabase(liquibase.database.core.SQLiteDatabase) DerbyDatabase(liquibase.database.core.DerbyDatabase) DB2Database(liquibase.database.core.DB2Database) H2Database(liquibase.database.core.H2Database) MSSQLDatabase(liquibase.database.core.MSSQLDatabase) MySQLDatabase(liquibase.database.core.MySQLDatabase) PostgresDatabase(liquibase.database.core.PostgresDatabase) OracleDatabase(liquibase.database.core.OracleDatabase) SybaseDatabase(liquibase.database.core.SybaseDatabase) SybaseASADatabase(liquibase.database.core.SybaseASADatabase) Database(liquibase.database.Database) HsqlDatabase(liquibase.database.core.HsqlDatabase) Sql(liquibase.sql.Sql) AbstractSqlGeneratorTest(liquibase.sqlgenerator.AbstractSqlGeneratorTest) Test(org.junit.Test)

Example 8 with HsqlDatabase

use of liquibase.database.core.HsqlDatabase in project liquibase by liquibase.

the class CreateTableGeneratorTest method testAutoIncrementStartWithHsqlDatabase.

@Test
public void testAutoIncrementStartWithHsqlDatabase() 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, null));
            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))", generatedSql[0].toSql());
        }
    }
}
Also used : HsqlDatabase(liquibase.database.core.HsqlDatabase) AutoIncrementConstraint(liquibase.statement.AutoIncrementConstraint) CreateTableStatement(liquibase.statement.core.CreateTableStatement) SQLiteDatabase(liquibase.database.core.SQLiteDatabase) DerbyDatabase(liquibase.database.core.DerbyDatabase) DB2Database(liquibase.database.core.DB2Database) H2Database(liquibase.database.core.H2Database) MSSQLDatabase(liquibase.database.core.MSSQLDatabase) MySQLDatabase(liquibase.database.core.MySQLDatabase) PostgresDatabase(liquibase.database.core.PostgresDatabase) OracleDatabase(liquibase.database.core.OracleDatabase) SybaseDatabase(liquibase.database.core.SybaseDatabase) SybaseASADatabase(liquibase.database.core.SybaseASADatabase) Database(liquibase.database.Database) HsqlDatabase(liquibase.database.core.HsqlDatabase) Sql(liquibase.sql.Sql) AbstractSqlGeneratorTest(liquibase.sqlgenerator.AbstractSqlGeneratorTest) Test(org.junit.Test)

Aggregations

HsqlDatabase (liquibase.database.core.HsqlDatabase)8 MSSQLDatabase (liquibase.database.core.MSSQLDatabase)5 OracleDatabase (liquibase.database.core.OracleDatabase)5 Sql (liquibase.sql.Sql)5 Test (org.junit.Test)5 Database (liquibase.database.Database)4 DB2Database (liquibase.database.core.DB2Database)4 DerbyDatabase (liquibase.database.core.DerbyDatabase)4 H2Database (liquibase.database.core.H2Database)4 MySQLDatabase (liquibase.database.core.MySQLDatabase)4 PostgresDatabase (liquibase.database.core.PostgresDatabase)4 SQLiteDatabase (liquibase.database.core.SQLiteDatabase)4 SybaseASADatabase (liquibase.database.core.SybaseASADatabase)4 SybaseDatabase (liquibase.database.core.SybaseDatabase)4 AbstractSqlGeneratorTest (liquibase.sqlgenerator.AbstractSqlGeneratorTest)4 AutoIncrementConstraint (liquibase.statement.AutoIncrementConstraint)4 CreateTableStatement (liquibase.statement.core.CreateTableStatement)4 File (java.io.File)1 BigInteger (java.math.BigInteger)1 OfflineConnection (liquibase.database.OfflineConnection)1