I chose to update my application and database to use UUIDs as primary key. As I'm trying to achieve this with as few changes to my application as possible, I thought about using mysql triggers.
This thread
Creating trigger in mysql for generation UUID
explains how to generate UUIDs on insert. But using it as a key attribute, I need to handle the unlikely case of collision. Is it possible to react to constraint violations by retrying the insert with a new UUID using mysql triggers?