@Override
    public void upgrade() {
        final DBCollection collection = mongoConnection.getDatabase().getCollection("preflight");

        final WriteResult result = collection.update(
                new BasicDBObject("result", new BasicDBObject("$exists", true)),
                new BasicDBObject(Map.of(
                        "$set", new BasicDBObject("type", "preflight_result"),
                        "$rename", new BasicDBObject("result", "value")
                )),
                false,
                true);

        collection.update(
                new BasicDBObject("type", "preflight_password"),
                new BasicDBObject("$setOnInsert", new BasicDBObject(Map.of(
                        "type", "preflight_password",
                        "value", RandomStringUtils.randomAlphabetic(PreflightConstants.INITIAL_PASSWORD_LENGTH)
                ))),
                true,
                false);
    }
@Test
    @MongoDBFixtures({"V20230929142900_CreateInitialPreflightPassword/old_preflight_config_structure.json"})
    void testMigrateConfigCreatePassword() {

        Assertions.assertThat(collection.countDocuments()).isEqualTo(1); // the old format of configuration, one doc
        migration.upgrade();
        Assertions.assertThat(collection.countDocuments()).isEqualTo(2); // the old format of configuration, one doc

        String result = (String) collection.find(Filters.eq("type", "preflight_result")).first().get("value");
        Assertions.assertThat(result).isEqualTo("FINISHED");



        String password = (String) collection.find(Filters.eq("type", "preflight_password")).first().get("value");
        Assertions.assertThat(password).hasSizeGreaterThanOrEqualTo(PreflightConstants.INITIAL_PASSWORD_LENGTH);
    }