@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
    @MongoDBFixtures("V20200409083200_RemoveRootQueriesFromMigratedDashboards/sample.json")
    public void findsCorrectDocuments() throws JsonProcessingException, JSONException {
        migration.upgrade();

        assertThat(rootQueryStrings("5d6ce7bd5d1eb45af534399e")).allMatch(String::isEmpty);
        assertThat(rootQueryStrings("5da9bc1b3a6a1d0d2f07faf2")).allMatch(String::isEmpty);
        assertThat(rootQueryStrings("5dad673d6131be4f08ceea77")).allMatch(String::isEmpty);
        assertThat(rootQueryStrings("5dbbf604799412036075d78f")).allMatch(String::isEmpty);

        assertThat(rootQueryStrings("5da9bbb944300ca38bc5da3e")).containsExactlyInAnyOrder("author:\"$author$\" AND project:\"graylog2-server\"", "author:\"$author$\"");
        assertThat(rootQueryStrings("5da9bbba12993f3904b41217")).containsExactlyInAnyOrder("author:\"$author$\" AND project:\"graylog2-server\"", "author:\"$author$\"");
    }