Search in sources :

Example 11 with AppliedMigration

use of org.flywaydb.core.internal.metadatatable.AppliedMigration in project flyway by flyway.

the class MigrationInfoImplSmallTest method validate.

@Test
public void validate() {
    MigrationVersion version = MigrationVersion.fromVersion("1");
    String description = "test";
    MigrationType type = MigrationType.SQL;
    ResolvedMigrationImpl resolvedMigration = new ResolvedMigrationImpl();
    resolvedMigration.setVersion(version);
    resolvedMigration.setDescription(description);
    resolvedMigration.setType(type);
    resolvedMigration.setChecksum(456);
    AppliedMigration appliedMigration = new AppliedMigration(1, version, description, type, null, 123, new Date(), "abc", 0, true);
    MigrationInfoImpl migrationInfo = new MigrationInfoImpl(resolvedMigration, appliedMigration, new MigrationInfoContext(), false);
    String message = migrationInfo.validate();
    assertTrue(message.contains("123"));
    assertTrue(message.contains("456"));
}
Also used : MigrationVersion(org.flywaydb.core.api.MigrationVersion) AppliedMigration(org.flywaydb.core.internal.metadatatable.AppliedMigration) MigrationType(org.flywaydb.core.api.MigrationType) ResolvedMigrationImpl(org.flywaydb.core.internal.resolver.ResolvedMigrationImpl) Date(java.util.Date) Test(org.junit.Test)

Example 12 with AppliedMigration

use of org.flywaydb.core.internal.metadatatable.AppliedMigration 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

AppliedMigration (org.flywaydb.core.internal.metadatatable.AppliedMigration)12 MigrationVersion (org.flywaydb.core.api.MigrationVersion)6 Test (org.junit.Test)6 SQLException (java.sql.SQLException)3 FlywayException (org.flywaydb.core.api.FlywayException)3 Date (java.util.Date)2 MigrationType (org.flywaydb.core.api.MigrationType)2 MigrationExecutor (org.flywaydb.core.api.resolver.MigrationExecutor)2 ResolvedMigration (org.flywaydb.core.api.resolver.ResolvedMigration)2 TransactionTemplate (org.flywaydb.core.internal.util.jdbc.TransactionTemplate)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 MigrationInfo (org.flywaydb.core.api.MigrationInfo)1 FlywayCallback (org.flywaydb.core.api.callback.FlywayCallback)1 FlywaySqlException (org.flywaydb.core.internal.dbsupport.FlywaySqlException)1 MigrationInfoImpl (org.flywaydb.core.internal.info.MigrationInfoImpl)1 MetaDataTable (org.flywaydb.core.internal.metadatatable.MetaDataTable)1 ResolvedMigrationImpl (org.flywaydb.core.internal.resolver.ResolvedMigrationImpl)1 Pair (org.flywaydb.core.internal.util.Pair)1