Created
July 12, 2021 06:53
-
-
Save finwe/5908d30a0c5e61ffd8e8d0fde78220a3 to your computer and use it in GitHub Desktop.
PostgreSQL gen_random_uuid polyfill for <13
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
DO $_$ | |
BEGIN | |
IF NOT EXISTS (SELECT 1 FROM pg_proc WHERE proname = 'gen_random_uuid') THEN | |
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | |
CREATE FUNCTION gen_random_uuid() | |
RETURNS uuid | |
LANGUAGE sql | |
AS $$ | |
SELECT uuid_generate_v4() | |
$$; | |
END IF; | |
END | |
$_$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment