For the base, mix 150 g flour and 1 pinch of salt in a bowl. Grate butter directly into the flour on a coarse grater. Mix everything briefly with a wooden spoon. Stir sour cream, lemon juice and 4 tablespoons of ice-cold water until smooth. Add to the flour mixture and mix first with a spoon, then briefly with your hands until all ingredients are combined. Wrap the dough in foil and refrigerate for about 1 hour.
Wash thyme and shake dry, remove leaves. Peel onions and dice them very roughly. Heat the oil in a large pan. Fry the onions in it while turning. Add thyme. Sprinkle onions with 2 tbsp. sugar, caramelise slightly. Deglaze with vinegar and wine. Season with salt and pepper. Bring to the boil and simmer on a low heat for 30-35 minutes until the liquid has evaporated. Stir several times. Remove from heat and allow to cool slightly.
Finely grate the cheese. Mix ricotta and half of the cheese, season with salt and pepper.
Preheat oven (electric cooker: 200 °C/circulating air: 175 °C/gas: see manufacturer). Line a tray with baking paper. Roll out the dough to a circle (approx. 28 cm Ø) on a floured work surface. Place on the baking tray. Spread the cheese cream on the dough, leaving a rim of approx. 4 cm all around. Spread the onion mixture over the cream. Place the edge of the dough all around the filling. Sprinkle the rest of the cheese on top. Bake in a hot oven on the lowest shelf for about 30 minutes.
In the meantime cut the ham into wide strips. Take the tart out of the oven. Let it rest for a short time. Cover with ham and garnish with chervil and strips of spring onion as desired.