RED-2171: Fixed rollback in migration because of exit 0
This commit is contained in:
parent
ab2a66eab0
commit
2a1a65b903
@ -162,20 +162,6 @@ public class MigrationService {
|
||||
|
||||
private final StorageService storageService;
|
||||
|
||||
private final FileManagementServiceSettings settings;
|
||||
private final ApplicationContext ctx;
|
||||
|
||||
|
||||
@Transactional
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
public void runMigration() {
|
||||
|
||||
if (settings.isMigrateOnly()) {
|
||||
migrate();
|
||||
System.exit(SpringApplication.exit(ctx, () -> 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@Transactional
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package com.iqser.red.service.peristence.v1.server.migration;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.peristence.v1.server.settings.FileManagementServiceSettings;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MigrationStarterService {
|
||||
|
||||
// This is a seperate class because exit 0 causes rollback if the method is @Transactional.
|
||||
|
||||
private final MigrationService migrationService;
|
||||
private final FileManagementServiceSettings settings;
|
||||
private final ApplicationContext ctx;
|
||||
|
||||
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
public void runMigration() {
|
||||
|
||||
if (settings.isMigrateOnly()) {
|
||||
migrationService.migrate();
|
||||
System.exit(SpringApplication.exit(ctx, () -> 0));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user