A cataclysmic collision changed the history of the Milky Way