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

        final UpdateResult updateResult = searchesCollection
                .updateMany(
                        and(
                                isDashboard(),
                                atLeastOneQueryHasNonEmptyQueryString()
                        ),
                        makeQueryStringEmpty(),
                        forNonEmptyQueryStrings()
                );

        writeMigrationCompleted(updateResult.getModifiedCount());
    }
@Test
    public void writesMigrationCompletedAfterSuccess() {
        this.migration.upgrade();

        final MigrationCompleted migrationCompleted = captureMigrationCompleted();
        assertThat(migrationCompleted.modifiedViewsCount()).isZero();
    }