@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 doesNotRunIfMigrationHasCompletedBefore() {
        when(clusterConfigService.get(MigrationCompleted.class)).thenReturn(MigrationCompleted.create(0));

        this.migration.upgrade();

        verify(viewsCollection, never()).find(any(Bson.class));
        verify(searchesCollection, never()).find(any(Bson.class));
    }