@Test public void shouldNotRepairEntryInOkStatus() throws Exception { mockEntry("4", "5", MigrationStatus.OK); final MigraMongoStatus status = migraMongo.repair("4", "5"); assertThat(status.status, is(MigrationStatus.ERROR)); assertThat(status.message, containsString("has already status '" + MigrationStatus.OK + "'")); assertThat(status.migrationsApplied, hasSize(0)); }
public MigraMongoStatus repair(String fromVersion, String toVersion) { final MigrationEntry migrationEntry = migrationHistoryService.findMigration(fromVersion, toVersion); if (migrationEntry == null) { return MigraMongoStatus .error( "No migration entry found for fromVersion '" + fromVersion + "' and toVersion '" + toVersion + "'"); } if (migrationEntry.getStatus() == MigrationStatus.OK) { return MigraMongoStatus .error( "Migration entry with fromVersion '" + fromVersion + "' and toVersion '" + toVersion + "' has already status '" + migrationEntry.getStatus() + "'. Nothing will be done"); } final MigrationStatus previousStatus = migrationEntry.getStatus(); final MigrationEntry correctedMigrationEntry = migrationHistoryService .setMigrationStatusToFinished(migrationEntry); final MigraMongoStatus status = MigraMongoStatus .ok( "Status of migrationEntry " + migrationEntry + " changed from '" + previousStatus + "' to '" + MigrationStatus.OK + "'"); status.addEntry(correctedMigrationEntry); return status; }
MigraMongo { public MigraMongoStatus repair(String fromVersion, String toVersion) { final MigrationEntry migrationEntry = migrationHistoryService.findMigration(fromVersion, toVersion); if (migrationEntry == null) { return MigraMongoStatus .error( "No migration entry found for fromVersion '" + fromVersion + "' and toVersion '" + toVersion + "'"); } if (migrationEntry.getStatus() == MigrationStatus.OK) { return MigraMongoStatus .error( "Migration entry with fromVersion '" + fromVersion + "' and toVersion '" + toVersion + "' has already status '" + migrationEntry.getStatus() + "'. Nothing will be done"); } final MigrationStatus previousStatus = migrationEntry.getStatus(); final MigrationEntry correctedMigrationEntry = migrationHistoryService .setMigrationStatusToFinished(migrationEntry); final MigraMongoStatus status = MigraMongoStatus .ok( "Status of migrationEntry " + migrationEntry + " changed from '" + previousStatus + "' to '" + MigrationStatus.OK + "'"); status.addEntry(correctedMigrationEntry); return status; } }
MigraMongo { public MigraMongoStatus repair(String fromVersion, String toVersion) { final MigrationEntry migrationEntry = migrationHistoryService.findMigration(fromVersion, toVersion); if (migrationEntry == null) { return MigraMongoStatus .error( "No migration entry found for fromVersion '" + fromVersion + "' and toVersion '" + toVersion + "'"); } if (migrationEntry.getStatus() == MigrationStatus.OK) { return MigraMongoStatus .error( "Migration entry with fromVersion '" + fromVersion + "' and toVersion '" + toVersion + "' has already status '" + migrationEntry.getStatus() + "'. Nothing will be done"); } final MigrationStatus previousStatus = migrationEntry.getStatus(); final MigrationEntry correctedMigrationEntry = migrationHistoryService .setMigrationStatusToFinished(migrationEntry); final MigraMongoStatus status = MigraMongoStatus .ok( "Status of migrationEntry " + migrationEntry + " changed from '" + previousStatus + "' to '" + MigrationStatus.OK + "'"); status.addEntry(correctedMigrationEntry); return status; } MigraMongo(
            MongoDatabase database,
            MigrationHistoryService migrationEntryService,
            LockService lockService,
            ScriptLookupService scriptLookupService); }
MigraMongo { public MigraMongoStatus repair(String fromVersion, String toVersion) { final MigrationEntry migrationEntry = migrationHistoryService.findMigration(fromVersion, toVersion); if (migrationEntry == null) { return MigraMongoStatus .error( "No migration entry found for fromVersion '" + fromVersion + "' and toVersion '" + toVersion + "'"); } if (migrationEntry.getStatus() == MigrationStatus.OK) { return MigraMongoStatus .error( "Migration entry with fromVersion '" + fromVersion + "' and toVersion '" + toVersion + "' has already status '" + migrationEntry.getStatus() + "'. Nothing will be done"); } final MigrationStatus previousStatus = migrationEntry.getStatus(); final MigrationEntry correctedMigrationEntry = migrationHistoryService .setMigrationStatusToFinished(migrationEntry); final MigraMongoStatus status = MigraMongoStatus .ok( "Status of migrationEntry " + migrationEntry + " changed from '" + previousStatus + "' to '" + MigrationStatus.OK + "'"); status.addEntry(correctedMigrationEntry); return status; } MigraMongo(
            MongoDatabase database,
            MigrationHistoryService migrationEntryService,
            LockService lockService,
            ScriptLookupService scriptLookupService); void setAsyncInitializerFunction(Runnable function); MigraMongoStatus dryRun(); MigraMongoStatus migrate(); MigraMongoStatus migrateAsync(); MigraMongoStatus status(String fromVersion); MigraMongoStatus repair(String fromVersion, String toVersion); MigraMongoStatus rerun(String fromVersion, String toVersion); List<MigrationEntry> getMigrationEntries(); void destroyLocks(); }
MigraMongo { public MigraMongoStatus repair(String fromVersion, String toVersion) { final MigrationEntry migrationEntry = migrationHistoryService.findMigration(fromVersion, toVersion); if (migrationEntry == null) { return MigraMongoStatus .error( "No migration entry found for fromVersion '" + fromVersion + "' and toVersion '" + toVersion + "'"); } if (migrationEntry.getStatus() == MigrationStatus.OK) { return MigraMongoStatus .error( "Migration entry with fromVersion '" + fromVersion + "' and toVersion '" + toVersion + "' has already status '" + migrationEntry.getStatus() + "'. Nothing will be done"); } final MigrationStatus previousStatus = migrationEntry.getStatus(); final MigrationEntry correctedMigrationEntry = migrationHistoryService .setMigrationStatusToFinished(migrationEntry); final MigraMongoStatus status = MigraMongoStatus .ok( "Status of migrationEntry " + migrationEntry + " changed from '" + previousStatus + "' to '" + MigrationStatus.OK + "'"); status.addEntry(correctedMigrationEntry); return status; } MigraMongo(
            MongoDatabase database,
            MigrationHistoryService migrationEntryService,
            LockService lockService,
            ScriptLookupService scriptLookupService); void setAsyncInitializerFunction(Runnable function); MigraMongoStatus dryRun(); MigraMongoStatus migrate(); MigraMongoStatus migrateAsync(); MigraMongoStatus status(String fromVersion); MigraMongoStatus repair(String fromVersion, String toVersion); MigraMongoStatus rerun(String fromVersion, String toVersion); List<MigrationEntry> getMigrationEntries(); void destroyLocks();  }