@Override
    public void upgrade() {
        if (clusterConfigService.get(MigrationCompleted.class) != null) {
            LOG.debug("Migration already completed.");
            return;
        }

        final LegacyAWSPluginConfiguration legacyConfiguration = clusterConfigService.get(
                CLUSTER_CONFIG_TYPE,
                LegacyAWSPluginConfiguration.class
        );

        if (legacyConfiguration != null && !Strings.isNullOrEmpty(legacyConfiguration.secretKey())) {
            final AWSPluginConfiguration migratedPluginConfiguration = AWSPluginConfiguration.fromLegacyConfig(legacyConfiguration, systemConfiguration);

            clusterConfigService.write(CLUSTER_CONFIG_TYPE, migratedPluginConfiguration);
        }

        clusterConfigService.write(MigrationCompleted.create());
    }
@Test
    public void doesNotDoAnyThingForMissingPluginConfig() {
        mockExistingConfig(null);

        this.migration.upgrade();

        verify(clusterConfigService, never()).write(anyString(), any());
        verify(clusterConfigService, times(1)).write(any(V20200505121200_EncryptAWSSecretKey.MigrationCompleted.class));
    }