Search in sources :

Example 1 with TagDatabaseStatement

use of liquibase.statement.core.TagDatabaseStatement 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 2 with TagDatabaseStatement

use of liquibase.statement.core.TagDatabaseStatement in project liquibase by liquibase.

the class TagDatabaseGeneratorTest method testMSSQL.

// //    @Test
// //    public void supports() throws Exception {
// //        new DatabaseTestTemplate().testOnAllDatabases(new DatabaseTest() {
// //            public void performTest(Database database) throws Exception {
// //                assertTrue(createGeneratorUnderTest().supportsDatabase(database));
// //            }
// //        });
// //    }
// 
// @Test
// public void execute() throws Exception {
// new DatabaseTestTemplate().testOnAvailableDatabases(
// new SqlStatementDatabaseTest(null, new TagDatabaseStatement("TAG_NAME")) {
// protected void setup(Database database) throws Exception {
// new Liquibase("changelogs/common/common.tests.changelog.xml", new JUnitResourceAccessor(), database).update(null);
// }
// 
// protected void preExecuteAssert(DatabaseSnapshotGenerator snapshot) throws DatabaseException {
// assertFalse(snapshot.getDatabase().doesTagExist("TAG_NAME"));
// }
// 
// protected void postExecuteAssert(DatabaseSnapshotGenerator snapshot) throws DatabaseException {
// assertTrue(snapshot.getDatabase().doesTagExist("TAG_NAME"));
// }
// 
// });
// }
@Test
public void testMSSQL() throws Exception {
    TagDatabaseStatement statement = new TagDatabaseStatement("v1.0");
    Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(statement, new MSSQLDatabase());
    assertEquals(1, sql.length);
    assertEquals("UPDATE changelog " + "SET TAG = 'v1.0' " + "FROM DATABASECHANGELOG AS changelog " + "INNER JOIN (" + "SELECT TOP (1) ID, AUTHOR, FILENAME " + "FROM DATABASECHANGELOG " + "ORDER BY DATEEXECUTED DESC, ORDEREXECUTED DESC" + ") AS latest " + "ON latest.ID = changelog.ID " + "AND latest.AUTHOR = changelog.AUTHOR " + "AND latest.FILENAME = changelog.FILENAME", sql[0].toSql());
}
Also used : TagDatabaseStatement(liquibase.statement.core.TagDatabaseStatement) MSSQLDatabase(liquibase.database.core.MSSQLDatabase) Sql(liquibase.sql.Sql) Test(org.junit.Test)

Aggregations

Sql (liquibase.sql.Sql)2 TagDatabaseStatement (liquibase.statement.core.TagDatabaseStatement)2 Test (org.junit.Test)2 HsqlDatabase (liquibase.database.core.HsqlDatabase)1 MSSQLDatabase (liquibase.database.core.MSSQLDatabase)1