Drizzle TeamDT
Drizzle Team3y ago
16 replies
imoby

Unable to generate uuid as primary key

Hey everyone! I've searched through the help posts with similar titles but I could not get the answer I wanted. I have a prisma current setup, and trying to switch over, but my uuid is generated as my postgres primary key but I keep getting the following error:

"null value in column \"id\" of relation \"User\" violates not-null constraint"

I've tried all of the following:

export const patient = pgTable('User', {
  id: uuid('id')
    .default(sql`uuid_generate_v7()`)
    .primaryKey()
    .defaultRandom()


  id: uuid('id').defaultRandom().primaryKey(),


and even the migration introspection tool set my id as this:
  id: text('id').primaryKey().notNull(),

which definitely didnt work. Any ideas?
Was this page helpful?