Search in sources :

Example 46 with MigrationVersion

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

the class DbMigrateWithDryRun method applyMigration.

private void applyMigration(final int installedRnk, final MigrationInfoImpl migration) {
    final MigrationVersion version = migration.getVersion();
    final String migrationText;
    if (version != null) {
        migrationText = "schema " + schema + " to version " + version + " - " + migration.getDescription();
    } else {
        migrationText = "schema " + schema + " with repeatable migration " + migration.getDescription();
    }
    LOG.info("Migrating " + migrationText);
    // PIERRE: override the executor to capture the SQL
    final FileSystemResource sqlScriptResource = new FileSystemResource(migration.getResolvedMigration().getPhysicalLocation());
    final MigrationExecutor migrationExecutor = new CapturingSqlMigrationExecutor(sqlStatements, dbSupport, sqlScriptResource, placeholderReplacer, encoding);
    try {
        doMigrate(migration, migrationExecutor, migrationText);
    } catch (final SQLException e) {
        throw new FlywayException("Unable to apply migration", e);
    }
    final AppliedMigration appliedMigration = new AppliedMigration(installedRnk, version, migration.getDescription(), migration.getType(), migration.getScript(), migration.getResolvedMigration().getChecksum(), null, null, -1, true);
    metaDataTableForDryRun.addAppliedMigration(appliedMigration);
}
Also used : FlywayException(org.flywaydb.core.api.FlywayException) MigrationVersion(org.flywaydb.core.api.MigrationVersion) SQLException(java.sql.SQLException) AppliedMigration(org.flywaydb.core.internal.metadatatable.AppliedMigration) MigrationExecutor(org.flywaydb.core.api.resolver.MigrationExecutor) FileSystemResource(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource)

Aggregations

MigrationVersion (org.flywaydb.core.api.MigrationVersion)46 Test (org.junit.Test)27 SQLException (java.sql.SQLException)10 MigrationInfo (org.flywaydb.core.api.MigrationInfo)10 ResolvedMigrationImpl (org.flywaydb.core.internal.resolver.ResolvedMigrationImpl)7 HashMap (java.util.HashMap)6 FlywayException (org.flywaydb.core.api.FlywayException)6 MigrationType (org.flywaydb.core.api.MigrationType)5 AppliedMigration (org.flywaydb.core.internal.metadatatable.AppliedMigration)5 MigrationInfoService (org.flywaydb.core.api.MigrationInfoService)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 FlywaySqlScriptException (org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 ResolvedMigration (org.flywaydb.core.api.resolver.ResolvedMigration)2 FlywaySqlException (org.flywaydb.core.internal.dbsupport.FlywaySqlException)2 FlywaySqlException (org.flywaydb.core.internal.exception.FlywaySqlException)2 PlaceholderReplacer (org.flywaydb.core.internal.util.PlaceholderReplacer)2