Preheat the oven to 180 C / Gas 4. Grease and lightly dust with flour a 23cm quiche dish or tart tin and line with the shortcrust pastry, cutting off any excess and pinching the edges.
Melt the butter in a frying pan over a medium heat. Add the onions and thyme and cook and stir until the onions become translucent and tender. Sprinkle caster sugar on top, and cook for another 4 minutes. Remove from heat and transfer to a bowl. Add soured cream, grated cheese and beaten eggs; season with salt and pepper and mix well. Pour the mixture into pastry base.
Bake in the preheated oven for 45 minutes, until the quiche is set in centre. Remove from the oven and allow to stand 10 minutes before serving.