Search in sources :

Example 21 with H2Database

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

the class ChangeLogParametersTest method setParameterValue_multiDatabase.

@Test
public void setParameterValue_multiDatabase() {
    ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
    changeLogParameters.set("doubleSet", "originalValue", new ContextExpression(), new Labels(), "baddb, h2", true, null);
    assertEquals("originalValue", changeLogParameters.getValue("doubleSet", null));
}
Also used : ContextExpression(liquibase.ContextExpression) Labels(liquibase.Labels) H2Database(liquibase.database.core.H2Database) Test(org.junit.Test)

Example 22 with H2Database

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

the class ChangeLogParametersTest method getParameterValue_MultipleLocalParametersInOneHierarchy.

@Test
public /**
 * master.xml
 * - table_1.xml (table.name=table_1 global=false)
 * - - include_of_table_1.xml
 * - - - include_of_include_of_table_1.xml
 *
 *  The same parameter defined multiple times on different levels of included files
 */
void getParameterValue_MultipleLocalParametersInOneHierarchy() {
    ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
    DatabaseChangeLog master = new DatabaseChangeLog("master.xml");
    DatabaseChangeLog table_1 = new DatabaseChangeLog("table_1.xml");
    table_1.setParentChangeLog(master);
    changeLogParameters.set("aKey", "aValue", "junit", "junitLabel", "baddb, h2", false, table_1);
    DatabaseChangeLog include_of_table_1 = new DatabaseChangeLog("include_of_table_1.xml");
    include_of_table_1.setParentChangeLog(table_1);
    DatabaseChangeLog include_of_include_of_table_1 = new DatabaseChangeLog("include_of_include_of_table_1.xml");
    include_of_include_of_table_1.setParentChangeLog(include_of_table_1);
    changeLogParameters.set("aKey", "bValue", "junit", "junitLabel", "baddb, h2", false, include_of_include_of_table_1);
    assertEquals("should return local value of changeSet", "bValue", changeLogParameters.getValue("aKey", include_of_include_of_table_1));
    assertEquals("should return local value of closest ancestor changeSet (here the direct parent)", "aValue", changeLogParameters.getValue("aKey", include_of_table_1));
    assertEquals("should return local value of changeSet", "aValue", changeLogParameters.getValue("aKey", table_1));
}
Also used : H2Database(liquibase.database.core.H2Database) Test(org.junit.Test)

Example 23 with H2Database

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

the class SqlGeneratorFactoryTest method getGenerators.

@Test
public void getGenerators() {
    SortedSet<SqlGenerator> allGenerators = SqlGeneratorFactory.getInstance().getGenerators(new AddAutoIncrementStatement(null, null, "person", "name", "varchar(255)", null, null, null, null), new H2Database());
    assertNotNull(allGenerators);
    assertEquals(1, allGenerators.size());
}
Also used : AddAutoIncrementStatement(liquibase.statement.core.AddAutoIncrementStatement) H2Database(liquibase.database.core.H2Database) Test(org.junit.Test)

Example 24 with H2Database

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

the class CreateTableGeneratorTest method testAutoIncrementStartWithH2Database.

@Test
public void testAutoIncrementStartWithH2Database() 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, null));
            Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
            assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT GENERATED BY DEFAULT AS IDENTITY (0))", generatedSql[0].toSql());
        }
    }
}
Also used : CreateTableStatement(liquibase.statement.core.CreateTableStatement) SQLiteDatabase(liquibase.database.core.SQLiteDatabase) DerbyDatabase(liquibase.database.core.DerbyDatabase) 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) AbstractDb2Database(liquibase.database.core.AbstractDb2Database) HsqlDatabase(liquibase.database.core.HsqlDatabase) H2Database(liquibase.database.core.H2Database) Sql(liquibase.sql.Sql) AbstractSqlGeneratorTest(liquibase.sqlgenerator.AbstractSqlGeneratorTest) Test(org.junit.Test)

Example 25 with H2Database

use of liquibase.database.core.H2Database 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());
        }
    }
}
Also used : CreateTableStatement(liquibase.statement.core.CreateTableStatement) SQLiteDatabase(liquibase.database.core.SQLiteDatabase) DerbyDatabase(liquibase.database.core.DerbyDatabase) 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) AbstractDb2Database(liquibase.database.core.AbstractDb2Database) HsqlDatabase(liquibase.database.core.HsqlDatabase) H2Database(liquibase.database.core.H2Database) Sql(liquibase.sql.Sql) AbstractSqlGeneratorTest(liquibase.sqlgenerator.AbstractSqlGeneratorTest) Test(org.junit.Test)

Aggregations

H2Database (liquibase.database.core.H2Database)25 Test (org.junit.Test)23 Database (liquibase.database.Database)7 MySQLDatabase (liquibase.database.core.MySQLDatabase)7 OracleDatabase (liquibase.database.core.OracleDatabase)7 MSSQLDatabase (liquibase.database.core.MSSQLDatabase)5 PostgresDatabase (liquibase.database.core.PostgresDatabase)5 Sql (liquibase.sql.Sql)5 AbstractSqlGeneratorTest (liquibase.sqlgenerator.AbstractSqlGeneratorTest)5 AbstractDb2Database (liquibase.database.core.AbstractDb2Database)4 DerbyDatabase (liquibase.database.core.DerbyDatabase)4 HsqlDatabase (liquibase.database.core.HsqlDatabase)4 SQLiteDatabase (liquibase.database.core.SQLiteDatabase)4 SybaseASADatabase (liquibase.database.core.SybaseASADatabase)4 SybaseDatabase (liquibase.database.core.SybaseDatabase)4 CreateTableStatement (liquibase.statement.core.CreateTableStatement)4 ContextExpression (liquibase.ContextExpression)3 Labels (liquibase.Labels)3 ColumnConfig (liquibase.change.ColumnConfig)3 SqlGeneratorChain (liquibase.sqlgenerator.SqlGeneratorChain)3