PostgreSQL function gen_random_uuid() not working
You need to load the pgcrypto extension in the current database/schema with
CREATE EXTENSION pgcrypto;
like this (tested with PostgreSQL 12):
# SELECT gen_random_uuid();
ERROR: function gen_random_uuid() does not exist
LINE 1: select gen_random_uuid();
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
# CREATE EXTENSION pgcrypto;
CREATE EXTENSION
# SELECT gen_random_uuid();
gen_random_uuid
--------------------------------------
19a12b49-a57a-4f1e-8e66-152be08e6165
(1 row)
if you want to access gen_random_uuid() or any uuid type spesific database in the PostgreSQL you have to define public instance name! if you can't find public instance name you can select pgcrypto -> Properties -> Definition
public.gen_random_uuid()
if you use in schema.prisma you can use like this
@id @default(dbgenerated("public.uuid_generate_v4()"))
Firstly, it's gen_random_uuid()
, not get_random_uuid()