Small fix for the AddEventIdAtCreationToLinks migration

Noticed that this migration fails if there are links to an agent that doesn't have any events. This makes it slightly safer to run.