use of org.sonar.server.platform.db.migration.step.MigrationStepsExecutor in project sonarqube by SonarSource.
the class SQDatabase method executeDbMigrations.
private void executeDbMigrations(NoopDatabase noopDatabase) {
SpringComponentContainer container = new SpringComponentContainer();
container.add(noopDatabase);
MigrationConfigurationModule migrationConfigurationModule = new MigrationConfigurationModule();
migrationConfigurationModule.configure(container);
// dependencies required by DB migrations
container.add(SonarRuntimeImpl.forSonarQube(Version.create(8, 0), SonarQubeSide.SERVER, SonarEdition.COMMUNITY));
container.add(UuidFactoryFast.getInstance());
container.add(System2.INSTANCE);
container.add(MapSettings.class);
container.startComponents();
MigrationContainer migrationContainer = new MigrationContainerImpl(container, H2StepExecutor.class);
MigrationSteps migrationSteps = migrationContainer.getComponentByType(MigrationSteps.class);
MigrationStepsExecutor executor = migrationContainer.getComponentByType(MigrationStepsExecutor.class);
executor.execute(migrationSteps.readAll());
}
use of org.sonar.server.platform.db.migration.step.MigrationStepsExecutor in project sonarqube by SonarSource.
the class MigrationEngineImpl method execute.
@Override
public void execute() {
MigrationContainer migrationContainer = new MigrationContainerImpl(serverContainer, MigrationStepsExecutorImpl.class);
boolean blueGreen = configuration.getBoolean(ProcessProperties.Property.BLUE_GREEN_ENABLED.getKey()).orElse(false);
try {
MigrationStepsExecutor stepsExecutor = migrationContainer.getComponentByType(MigrationStepsExecutor.class);
Optional<Long> lastMigrationNumber = migrationHistory.getLastMigrationNumber();
List<RegisteredMigrationStep> steps = lastMigrationNumber.map(i -> migrationSteps.readFrom(i + 1)).orElse(migrationSteps.readAll());
if (blueGreen) {
ensureSupportBlueGreen(steps);
}
stepsExecutor.execute(steps);
} finally {
migrationContainer.cleanup();
}
}
Aggregations