Preheat oven to 170°C and warm a baking sheet inside.
Melt butter and sugar in a pan, add thyme sprigs, and arrange halved onions cut-side down.
Season with salt, pepper, chopped thyme, and vinegar, then cook on the hob for 10 minutes.
Cover pan with foil and bake on the baking sheet at 170°C for 50-60 minutes.
Process flour, butter, cheese, and thyme into crumbs, then mix with water to form a dough.
Chill the dough in the fridge for 30 minutes.
Remove onions from oven, increase heat to 200°C, and reduce pan juices on the hob until syrupy.
Roll pastry to a 25cm circle and tuck over the onions in the pan.
Bake tart at 200°C for 25-30 minutes until the pastry is golden.
Cool for 20 minutes before inverting onto a flat plate.