use of liquibase.sqlgenerator.MockSqlGeneratorChain 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.sqlgenerator.MockSqlGeneratorChain 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());
}
use of liquibase.sqlgenerator.MockSqlGeneratorChain in project liquibase by liquibase.
the class AddColumnGeneratorTest method testAddMultipleColumnsMySql.
@Test
public void testAddMultipleColumnsMySql() {
AddColumnStatement columns = new AddColumnStatement(new AddColumnStatement(null, null, TABLE_NAME, "column1", "INT", null, new NotNullConstraint()), new AddColumnStatement(null, null, TABLE_NAME, "column2", "INT", null, new NotNullConstraint()));
assertFalse(generatorUnderTest.validate(columns, new MySQLDatabase(), new MockSqlGeneratorChain()).hasErrors());
Sql[] sql = generatorUnderTest.generateSql(columns, new MySQLDatabase(), new MockSqlGeneratorChain());
assertEquals(1, sql.length);
assertEquals("ALTER TABLE " + TABLE_NAME + " ADD column1 INT NOT NULL, ADD column2 INT NOT NULL", sql[0].toSql());
assertEquals("[DEFAULT, table_name, table_name.column1, table_name.column2]", String.valueOf(sql[0].getAffectedDatabaseObjects()));
}
use of liquibase.sqlgenerator.MockSqlGeneratorChain in project liquibase by liquibase.
the class MarkChangeSetRanGeneratorTest method generateSql_markRan.
@Test
public void generateSql_markRan() {
Sql[] sqls = new MarkChangeSetRanGenerator().generateSql(new MarkChangeSetRanStatement(new ChangeSet("1", "a", false, false, "c", null, null, null), ChangeSet.ExecType.MARK_RAN), new MockDatabase(), new MockSqlGeneratorChain());
assertEquals(1, sqls.length);
assertTrue(sqls[0].toSql(), sqls[0].toSql().contains("MARK_RAN"));
}
use of liquibase.sqlgenerator.MockSqlGeneratorChain in project liquibase by liquibase.
the class AddColumnGeneratorDefaultClauseBeforeNotNullTest method validate_noAutoIncrementWithDerby.
@Test
public void validate_noAutoIncrementWithDerby() {
ValidationErrors validationErrors = generatorUnderTest.validate(new AddColumnStatement(null, null, "table_name", "column_name", "int", null, new AutoIncrementConstraint("column_name")), new DerbyDatabase(), new MockSqlGeneratorChain());
assertTrue(validationErrors.getErrorMessages().contains("Cannot add an identity column to derby"));
}
Aggregations