Created
March 11, 2018 21:39
-
-
Save seanbehan/9bf205793b5ab19f099118b947e484d8 to your computer and use it in GitHub Desktop.
MySQL Trigger for Default UUID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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