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

        var result = this.usersCollections.bulkWrite(List.of(
                new UpdateManyModel<>(Filters.eq(THEME_MODE_KEY, "teint"), Updates.set(THEME_MODE_KEY, "light")),
                new UpdateManyModel<>(Filters.eq(THEME_MODE_KEY, "noir"), Updates.set(THEME_MODE_KEY, "dark"))
        ));

        if (result.wasAcknowledged()) {
            configService.write(new MigrationCompleted(result.getMatchedCount(), result.getModifiedCount()));
        }
    }
@Test
    @MongoDBFixtures({"V20230904073300_MigrateThemePreferences/users_with_theme_preferences.json"})
    void migratesUsersWithExistingPreferences() {
        this.migration.upgrade();

        var gary = usersCollection.find(Filters.eq("username", "gary")).first();
        assertThat(gary.getEmbedded(List.of("preferences", "themeMode"), String.class)).isEqualTo("dark");
        var lightgary = usersCollection.find(Filters.eq("username", "lightgary")).first();
        assertThat(lightgary.getEmbedded(List.of("preferences", "themeMode"), String.class)).isEqualTo("light");

        assertThat(migrationMarkerIsWritten()).satisfies(migrationMarker -> {
            assertThat(migrationMarker.matched()).isEqualTo(2L);
            assertThat(migrationMarker.modified()).isEqualTo(2L);
        });
    }