gen_random_uuid not working

da1zHOBBY

a year ago

hi. I am trying to use postgress db provisioned on railway with drizzle. my schema look like
id: uuid('id').default(sql'gen_random_uuid()')
but on insert into this db I get error
PostgresError: null value in column "id" of relation "file" violates not-null constraint

is it possible that my db does not have this function? if so what should I do to create column with autogenerated uuid ? thanks!

Solved

0 Replies

da1zHOBBY

a year ago

60fd5f13-1cb6-475b-81c4-4b1e7803c705


a year ago

you would first need to enable the pgcrypto extension, do that by running this query -

CREATE EXTENSION pgcrypto;

Status changed to Solved railway[bot] about 1 year ago