Search in sources :

Example 6 with MySQLDatabase

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

the class ChangeMetaDataTest method getOptionalParameters.

@Test
public void getOptionalParameters() {
    HashSet<ChangeParameterMetaData> parameters = new HashSet<ChangeParameterMetaData>();
    parameters.add(new ChangeParameterMetaData(new ExampleAbstractChange(), "noneRequired", "x", null, null, null, Integer.class, new String[] { "none" }, null, null, null));
    parameters.add(new ChangeParameterMetaData(new ExampleAbstractChange(), "allRequired", "x", null, null, null, Integer.class, new String[] { "all" }, null, null, null));
    parameters.add(new ChangeParameterMetaData(new ExampleAbstractChange(), "h2Required", "x", null, null, null, Integer.class, new String[] { "h2" }, null, null, null));
    parameters.add(new ChangeParameterMetaData(new ExampleAbstractChange(), "oracleRequired", "x", null, null, null, Integer.class, new String[] { "oracle" }, null, null, null));
    ChangeMetaData changeMetaData = new ChangeMetaData("x", "y", 1, null, null, parameters);
    assertSetsEqual(new String[] { "noneRequired", "oracleRequired" }, changeMetaData.getOptionalParameters(new H2Database()).keySet());
    assertSetsEqual(new String[] { "noneRequired", "h2Required" }, changeMetaData.getOptionalParameters(new OracleDatabase()).keySet());
    assertSetsEqual(new String[] { "noneRequired", "h2Required", "oracleRequired" }, changeMetaData.getOptionalParameters(new MySQLDatabase()).keySet());
}
Also used : OracleDatabase(liquibase.database.core.OracleDatabase) MySQLDatabase(liquibase.database.core.MySQLDatabase) H2Database(liquibase.database.core.H2Database) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with MySQLDatabase

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

the class ChangeLogIteratorTest method runChangeSet_reverseVisitor.

@Test
public void runChangeSet_reverseVisitor() throws Exception {
    TestChangeSetVisitor testChangeLogVisitor = new ReverseChangeSetVisitor();
    ChangeLogIterator iterator = new ChangeLogIterator(changeLog, new ContextChangeSetFilter(new Contexts("test1")), new DbmsChangeSetFilter(new MySQLDatabase()));
    iterator.run(testChangeLogVisitor, new RuntimeEnvironment(null, null, null));
    assertEquals(3, testChangeLogVisitor.visitedChangeSets.size());
    assertEquals("5", testChangeLogVisitor.visitedChangeSets.get(0).getId());
    assertEquals("4", testChangeLogVisitor.visitedChangeSets.get(1).getId());
    assertEquals("1", testChangeLogVisitor.visitedChangeSets.get(2).getId());
}
Also used : RuntimeEnvironment(liquibase.RuntimeEnvironment) ContextChangeSetFilter(liquibase.changelog.filter.ContextChangeSetFilter) MySQLDatabase(liquibase.database.core.MySQLDatabase) DbmsChangeSetFilter(liquibase.changelog.filter.DbmsChangeSetFilter) Contexts(liquibase.Contexts) Test(org.junit.Test)

Example 8 with MySQLDatabase

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

the class DbmsChangeSetFilterTest method singleDbms.

//    @Test
//    public void emptyDbms() {
//        DbmsChangeSetFilter filter = new DbmsChangeSetFilter();
//
//        assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, null, "mysql")));
//        assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, null, "oracle")));
//        assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, null, "oracle, mysql")));
//        assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, null, null)));
//    }
@Test
public void singleDbms() {
    DbmsChangeSetFilter filter = new DbmsChangeSetFilter(new MySQLDatabase());
    assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, null, "mysql", null)).isAccepted());
    assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, null, "mysql, oracle", null)).isAccepted());
    assertFalse(filter.accepts(new ChangeSet(null, null, false, false, null, null, "oracle", null)).isAccepted());
    assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, null, null, null)).isAccepted());
    assertFalse(filter.accepts(new ChangeSet(null, null, false, false, null, null, "h2,!mysql", null)).isAccepted());
}
Also used : MySQLDatabase(liquibase.database.core.MySQLDatabase) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Example 9 with MySQLDatabase

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

the class DropColumnGeneratorTest method testDropMultipleColumnsMySQL.

@Test
public void testDropMultipleColumnsMySQL() {
    DropColumnStatement drop = new DropColumnStatement(Arrays.asList(new DropColumnStatement(null, null, "TEST_TABLE", "col1"), new DropColumnStatement(null, null, "TEST_TABLE", "col2")));
    Assert.assertFalse(generatorUnderTest.validate(drop, new MySQLDatabase(), new MockSqlGeneratorChain()).hasErrors());
    Sql[] sql = generatorUnderTest.generateSql(drop, new MySQLDatabase(), new MockSqlGeneratorChain());
    Assert.assertEquals(1, sql.length);
    Assert.assertEquals("ALTER TABLE TEST_TABLE DROP col1, DROP col2", sql[0].toSql());
    Assert.assertEquals("[DEFAULT, TEST_TABLE, TEST_TABLE.col1, TEST_TABLE.col2]", String.valueOf(sql[0].getAffectedDatabaseObjects()));
}
Also used : MySQLDatabase(liquibase.database.core.MySQLDatabase) DropColumnStatement(liquibase.statement.core.DropColumnStatement) MockSqlGeneratorChain(liquibase.sqlgenerator.MockSqlGeneratorChain) Sql(liquibase.sql.Sql) AbstractSqlGeneratorTest(liquibase.sqlgenerator.AbstractSqlGeneratorTest) Test(org.junit.Test)

Example 10 with MySQLDatabase

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

the class AddColumnGeneratorTest method testAddColumnAfter.

@Test
public void testAddColumnAfter() {
    AddColumnStatement statement = new AddColumnStatement(null, null, TABLE_NAME, COLUMN_NAME, COLUMN_TYPE, null);
    statement.setAddAfterColumn("column_after");
    assertFalse(generatorUnderTest.validate(statement, new MySQLDatabase(), new MockSqlGeneratorChain()).hasErrors());
}
Also used : MySQLDatabase(liquibase.database.core.MySQLDatabase) AddColumnStatement(liquibase.statement.core.AddColumnStatement) MockSqlGeneratorChain(liquibase.sqlgenerator.MockSqlGeneratorChain) Test(org.junit.Test) AbstractSqlGeneratorTest(liquibase.sqlgenerator.AbstractSqlGeneratorTest)

Aggregations

MySQLDatabase (liquibase.database.core.MySQLDatabase)21 Test (org.junit.Test)14 OracleDatabase (liquibase.database.core.OracleDatabase)9 MSSQLDatabase (liquibase.database.core.MSSQLDatabase)7 Sql (liquibase.sql.Sql)7 H2Database (liquibase.database.core.H2Database)6 AbstractSqlGeneratorTest (liquibase.sqlgenerator.AbstractSqlGeneratorTest)6 Database (liquibase.database.Database)5 DB2Database (liquibase.database.core.DB2Database)5 PostgresDatabase (liquibase.database.core.PostgresDatabase)5 DerbyDatabase (liquibase.database.core.DerbyDatabase)4 SQLiteDatabase (liquibase.database.core.SQLiteDatabase)4 MockSqlGeneratorChain (liquibase.sqlgenerator.MockSqlGeneratorChain)4 AutoIncrementConstraint (liquibase.statement.AutoIncrementConstraint)4 CreateTableStatement (liquibase.statement.core.CreateTableStatement)4 HsqlDatabase (liquibase.database.core.HsqlDatabase)3 SybaseASADatabase (liquibase.database.core.SybaseASADatabase)3 SybaseDatabase (liquibase.database.core.SybaseDatabase)3 LiquibaseDataType (liquibase.datatype.LiquibaseDataType)3 AddColumnStatement (liquibase.statement.core.AddColumnStatement)3