@Override
    public void upgrade() {
        MongoCollection<Document> roles = mongoDatabase.getCollection("roles");

        Document viewsUserRole = roles.findOneAndDelete(eq("name", "Views User"));

        if (viewsUserRole != null) {
            removeRoleFromUsers(viewsUserRole);
        }
    }
@Test
    public void removesReferenceToRoleFromUsers() {
        Document viewsUserRole = insertRole("Views User");
        Document otherRole = insertRole("Some Other Role");

        insertUserWithRoles(otherRole);
        Document userBefore = insertUserWithRoles(viewsUserRole, otherRole);

        migration.upgrade();

        Document userAfter = usersCollection.find(new Document().append("_id", userBefore.get("_id"))).first();

        assertThat(getList(userAfter, "roles")).containsOnly(otherRole.getObjectId("_id"));
    }