PostgreSQL function gen_random_uuid() not working

Viewed 52343

I get function get_random_uuid() does not exist error when running this SQL:

ALTER TABLE "posts" ALTER COLUMN "id" SET DEFAULT gen_random_uuid()

I can see pgcrypto module listed in this query select * from pg_available_extensions;. I'm using PostgreSQL 9.4.5 on Ubuntu 14.04.

Did I miss something?

4 Answers

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()"))
Related