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());
}
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());
}
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());
}
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()));
}
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());
}
Aggregations