Title pretty much says it all. Which one takes place first? It would be pretty handy to know with the great pit upgrades and how much defense you need.
From the help page:
Just before the midnight attack, the upgrade which has received the most votes is accepted and constructed immediately.
So, it happens before the attack, making the Great Pit upgrade useful if you need that one edge.