Search in sources :

Example 31 with MigrationVersion

use of org.flywaydb.core.api.MigrationVersion in project flyway by flyway.

the class H2MigrationMediumTest method dollarQuotedString.

@Test
public void dollarQuotedString() throws Exception {
    flyway.setLocations("migration/dbsupport/h2/sql/dollar_quoted_string");
    flyway.migrate();
    MigrationVersion version = flyway.info().current().getVersion();
    assertEquals("1.1", version.toString());
    assertEquals("Populate table", flyway.info().current().getDescription());
    assertEquals("'Mr. Semicolon+Linebreak;\nanother line'", jdbcTemplate.queryForString("select name from test_user where name like '%line'''"));
}
Also used : MigrationVersion(org.flywaydb.core.api.MigrationVersion) Test(org.junit.Test)

Example 32 with MigrationVersion

use of org.flywaydb.core.api.MigrationVersion in project flyway by flyway.

the class H2MigrationMediumTest method sequence.

@Test
public void sequence() throws Exception {
    flyway.setLocations("migration/dbsupport/h2/sql/sequence");
    flyway.migrate();
    MigrationVersion version = flyway.info().current().getVersion();
    assertEquals("1", version.toString());
    assertEquals("Sequence", flyway.info().current().getDescription());
    assertEquals(666, jdbcTemplate.queryForInt("select nextval('the_beast')"));
    flyway.clean();
    flyway.migrate();
}
Also used : MigrationVersion(org.flywaydb.core.api.MigrationVersion) Test(org.junit.Test)

Example 33 with MigrationVersion

use of org.flywaydb.core.api.MigrationVersion in project flyway by flyway.

the class DB2zOSMigrationMediumTest method sequence.

@Test
public void sequence() throws Exception {
    flyway.setLocations(getSequenceLocation());
    flyway.baseline();
    flyway.migrate();
    MigrationVersion migrationVersion = flyway.info().current().getVersion();
    assertEquals("1.1", migrationVersion.toString());
    assertEquals("Sequence", flyway.info().current().getDescription());
    assertEquals(666, jdbcTemplate.queryForInt("SELECT NEXTVAL FOR AURINT.beast_seq FROM sysibm.sysdummy1"));
}
Also used : MigrationVersion(org.flywaydb.core.api.MigrationVersion) Test(org.junit.Test)

Example 34 with MigrationVersion

use of org.flywaydb.core.api.MigrationVersion in project flyway by flyway.

the class OracleMigrationMediumTest method migrationsWithPlaceholders.

/**
     * Tests migrations containing placeholders.
     */
@Test
public void migrationsWithPlaceholders() throws Exception {
    int countUserObjects1 = jdbcTemplate.queryForInt("SELECT count(*) FROM user_objects");
    Map<String, String> placeholders = new HashMap<String, String>();
    placeholders.put("tableName", "test_user");
    flyway.setPlaceholders(placeholders);
    flyway.setLocations("migration/dbsupport/oracle/sql/placeholders");
    flyway.migrate();
    MigrationVersion version = flyway.info().current().getVersion();
    assertEquals("1.1", version.toString());
    assertEquals("Populate table", flyway.info().current().getDescription());
    assertEquals("Mr. T triggered", jdbcTemplate.queryForString("select name from test_user"));
    flyway.clean();
    int countUserObjects2 = jdbcTemplate.queryForInt("SELECT count(*) FROM user_objects");
    assertEquals(countUserObjects1, countUserObjects2);
    MigrationInfo[] migrationInfos = flyway.info().applied();
    for (MigrationInfo migrationInfo : migrationInfos) {
        assertNotNull(migrationInfo.getScript() + " has no checksum", migrationInfo.getChecksum());
    }
}
Also used : MigrationInfo(org.flywaydb.core.api.MigrationInfo) MigrationVersion(org.flywaydb.core.api.MigrationVersion) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 35 with MigrationVersion

use of org.flywaydb.core.api.MigrationVersion in project flyway by flyway.

the class SapHanaMigrationMediumTest method synonym.

@Test
public void synonym() throws Exception {
    flyway.setLocations("migration/dbsupport/saphana/sql/synonym");
    flyway.migrate();
    MigrationVersion version = flyway.info().current().getVersion();
    assertEquals("1", version.toString());
    assertEquals("Synonym", flyway.info().current().getDescription());
    flyway.clean();
    flyway.migrate();
}
Also used : MigrationVersion(org.flywaydb.core.api.MigrationVersion) Test(org.junit.Test)

Aggregations

MigrationVersion (org.flywaydb.core.api.MigrationVersion)40 Test (org.junit.Test)27 SQLException (java.sql.SQLException)9 MigrationInfo (org.flywaydb.core.api.MigrationInfo)8 FlywayException (org.flywaydb.core.api.FlywayException)7 HashMap (java.util.HashMap)6 AppliedMigration (org.flywaydb.core.internal.metadatatable.AppliedMigration)6 ResolvedMigrationImpl (org.flywaydb.core.internal.resolver.ResolvedMigrationImpl)6 MigrationType (org.flywaydb.core.api.MigrationType)4 ArrayList (java.util.ArrayList)3 MigrationChecksumProvider (org.flywaydb.core.api.migration.MigrationChecksumProvider)3 MigrationInfoProvider (org.flywaydb.core.api.migration.MigrationInfoProvider)3 MigrationExecutor (org.flywaydb.core.api.resolver.MigrationExecutor)3 ResolvedMigration (org.flywaydb.core.api.resolver.ResolvedMigration)3 FlywaySqlScriptException (org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException)3 Date (java.util.Date)2 FlywaySqlException (org.flywaydb.core.internal.dbsupport.FlywaySqlException)2 PlaceholderReplacer (org.flywaydb.core.internal.util.PlaceholderReplacer)2 StopWatch (org.flywaydb.core.internal.util.StopWatch)2 TransactionTemplate (org.flywaydb.core.internal.util.jdbc.TransactionTemplate)2