Search in sources :

Example 6 with DbSupport

use of org.flywaydb.core.internal.dbsupport.DbSupport in project flyway by flyway.

the class ConcurrentMigrationTestCase 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));
    }
    concurrentMigrationDataSource = createDataSource(customProperties);
    Connection connection = concurrentMigrationDataSource.getConnection();
    final DbSupport dbSupport = DbSupportFactory.createDbSupport(connection, false);
    schemaName = getSchemaName(dbSupport);
    schemaQuoted = dbSupport.quote(schemaName);
    connection.close();
    flyway = createFlyway();
    flyway.clean();
    if (needsBaseline()) {
        flyway.baseline();
    }
}
Also used : Connection(java.sql.Connection) DbSupport(org.flywaydb.core.internal.dbsupport.DbSupport) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) Before(org.junit.Before)

Example 7 with DbSupport

use of org.flywaydb.core.internal.dbsupport.DbSupport 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 8 with DbSupport

use of org.flywaydb.core.internal.dbsupport.DbSupport in project CzechIdMng by bcvsolutions.

the class IdmFlywayMigrationStrategy method resolveDbName.

/**
 * Resolve dbName, which is used by {@Flyway} datasource.
 *
 * @param flyway
 * @return
 */
public String resolveDbName(FlywayConfiguration flyway) {
    Connection connection = JdbcUtils.openConnection(flyway.getDataSource());
    DbSupport dbSupport = DbSupportFactory.createDbSupport(connection, false);
    return dbSupport.getDbName();
}
Also used : Connection(java.sql.Connection) DbSupport(org.flywaydb.core.internal.dbsupport.DbSupport)

Aggregations

DbSupport (org.flywaydb.core.internal.dbsupport.DbSupport)8 Connection (java.sql.Connection)7 Properties (java.util.Properties)3 FlywayCallback (org.flywaydb.core.api.callback.FlywayCallback)3 MigrationResolver (org.flywaydb.core.api.resolver.MigrationResolver)3 Schema (org.flywaydb.core.internal.dbsupport.Schema)3 MetaDataTable (org.flywaydb.core.internal.metadatatable.MetaDataTable)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 SQLException (java.sql.SQLException)2 Flyway (org.flywaydb.core.Flyway)2 FlywayException (org.flywaydb.core.api.FlywayException)2 SqlScriptFlywayCallback (org.flywaydb.core.internal.callback.SqlScriptFlywayCallback)2 CompositeMigrationResolver (org.flywaydb.core.internal.resolver.CompositeMigrationResolver)2 Test (org.junit.Test)2 Hashing (com.google.common.hash.Hashing)1 ByteSource (com.google.common.io.ByteSource)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1