Which order to paint ceiling and replace downlights?
In most cases you want to


Remove the old fixtures (or at least the bulb portion). These typically have a flange that covers the ugly hole in the drywall
Paint
Replace fixtures


If you do it this way, you can paint around the hole itself and then the fixture will hide it. Painting around fixtures is a pain, and you're making more work doing in in any other order.