Heat the olive oil in a large skillet on medium heat. When the oil is hot, add the onions and stir to spread out in the pan. Cook for approximately 10 minutes, or until translucent. Stir frequently. Turn the heat down to low and cook for another 15 minutes, or until nicely caramelized. Increase the heat medium ad add the wine, sugar, and salt. Stir well. Cook for approximately 20 to 30 minutes, or until the wine has dissolved and the onions are a deep purple. For the best flavor, allow the onion confit to set overnight in the fridge.
Preheat oven to 400°F (204°C) and line a baking sheet with parchment paper.
Use a 2-inch (5 cm) round cookie cutter to cut out circles of pastry dough and prick them with a fork about four times. Add a mound of the onion confit to the center of each circle, top with a dollop of the ricotta and sprinkle with a sprig of thyme. Bake for 15 minutes, or until the pastry is puffy and golden brown.