Skip to content

Instantly share code, notes, and snippets.

@seanbehan
Created March 11, 2018 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanbehan/9bf205793b5ab19f099118b947e484d8 to your computer and use it in GitHub Desktop.
Save seanbehan/9bf205793b5ab19f099118b947e484d8 to your computer and use it in GitHub Desktop.
MySQL Trigger for Default UUID
-- if uuid is set use that, otherwise create uuid
create trigger trigger_defaults_on_users
before insert on users
for each row
set new.uuid = coalesce(nullif(new.uuid, ''), uuid())
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment