Search in sources :

Example 26 with Flyway

use of org.flywaydb.core.Flyway in project flyway by flyway.

the class MySQLMigrationMediumTest method migrateWithNonExistingSchemaSetInPropertyButNotInUrl.

@Test
public void migrateWithNonExistingSchemaSetInPropertyButNotInUrl() throws Exception {
    Flyway flyway = new Flyway();
    flyway.setDataSource("jdbc:mysql://localhost/flyway_db", "flyway", "flyway");
    flyway.setSchemas("non-existing-schema");
    flyway.setLocations(BASEDIR);
    flyway.clean();
    assertEquals(4, flyway.migrate());
}
Also used : Flyway(org.flywaydb.core.Flyway) Test(org.junit.Test)

Example 27 with Flyway

use of org.flywaydb.core.Flyway in project flyway by flyway.

the class MySQLMigrationMediumTest method migrateWithExistingSchemaSetInPropertyButNotInUrl.

@Test
public void migrateWithExistingSchemaSetInPropertyButNotInUrl() throws Exception {
    Flyway flyway = new Flyway();
    flyway.setDataSource("jdbc:mysql://localhost/flyway_db", "flyway", "flyway");
    flyway.setSchemas("flyway_db");
    flyway.setLocations(getBasedir());
    flyway.clean();
    assertEquals(4, flyway.migrate());
}
Also used : Flyway(org.flywaydb.core.Flyway) Test(org.junit.Test)

Example 28 with Flyway

use of org.flywaydb.core.Flyway in project flyway by flyway.

the class SQLiteMigrationMediumTest method singleConnectionExternalDataSource.

@Test
public void singleConnectionExternalDataSource() {
    SQLiteConfig config = new SQLiteConfig();
    config.setJournalMode(SQLiteConfig.JournalMode.WAL);
    config.setSynchronous(SQLiteConfig.SynchronousMode.NORMAL);
    SQLiteDataSource dataSource = new SQLiteDataSource(config);
    dataSource.setUrl("jdbc:sqlite:target/single_external");
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.setLocations("migration/sql");
    flyway.clean();
    flyway.migrate();
}
Also used : SQLiteDataSource(org.sqlite.SQLiteDataSource) Flyway(org.flywaydb.core.Flyway) SQLiteConfig(org.sqlite.SQLiteConfig) Test(org.junit.Test)

Example 29 with Flyway

use of org.flywaydb.core.Flyway in project flyway by flyway.

the class SQLServerCaseSensitiveMigrationTestCase method caseSensitiveCollation.

@Test
public void caseSensitiveCollation() throws Exception {
    File customPropertiesFile = new File(System.getProperty("user.home") + "/flyway-mediumtests.properties");
    Properties customProperties = new Properties();
    if (customPropertiesFile.canRead()) {
        customProperties.load(new FileInputStream(customPropertiesFile));
    }
    DataSource dataSource = createDataSource(customProperties);
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.setLocations("migration/sql");
    flyway.clean();
    flyway.migrate();
    assertEquals("2.0", flyway.info().current().getVersion().toString());
    assertEquals(0, flyway.migrate());
    assertEquals(4, flyway.info().applied().length);
    Connection connection = dataSource.getConnection();
    DbSupport dbSupport = DbSupportFactory.createDbSupport(connection, true);
    assertEquals(2, dbSupport.getJdbcTemplate().queryForInt("select count(*) from all_misters"));
    connection.close();
}
Also used : Flyway(org.flywaydb.core.Flyway) Connection(java.sql.Connection) DbSupport(org.flywaydb.core.internal.dbsupport.DbSupport) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 30 with Flyway

use of org.flywaydb.core.Flyway in project flyway by flyway.

the class EnterpriseDBSuperUserMigrationMediumTest method setUp.

@Before
public void setUp() throws Exception {
    File customPropertiesFile = new File(System.getProperty("user.home") + "/flyway-mediumtests.properties");
    Properties customProperties = new Properties();
    if (customPropertiesFile.canRead()) {
        customProperties.load(new FileInputStream(customPropertiesFile));
    }
    String password = customProperties.getProperty("enterprisedb.password", "flyway");
    String url = customProperties.getProperty("enterprisedb.url", "jdbc:edb://localhost/flyway_db");
    flyway = new Flyway();
    flyway.setSchemas("super_user_test");
    flyway.setDataSource(new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, url, "flyway", password, new Properties()));
    flyway.setValidateOnMigrate(true);
    flyway.clean();
}
Also used : Flyway(org.flywaydb.core.Flyway) DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) Before(org.junit.Before)

Aggregations

Flyway (org.flywaydb.core.Flyway)44 Test (org.junit.Test)26 Connection (java.sql.Connection)7 DriverDataSource (org.flywaydb.core.internal.util.jdbc.DriverDataSource)6 File (java.io.File)5 SQLException (java.sql.SQLException)5 Properties (java.util.Properties)5 DataSource (javax.sql.DataSource)5 MetricRegistry (com.codahale.metrics.MetricRegistry)4 Statement (java.sql.Statement)4 FlywayException (org.flywaydb.core.api.FlywayException)4 FileInputStream (java.io.FileInputStream)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 MavenProject (org.apache.maven.project.MavenProject)2 MigrationInfo (org.flywaydb.core.api.MigrationInfo)2 DbSupport (org.flywaydb.core.internal.dbsupport.DbSupport)2 Before (org.junit.Before)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1