CUID as my id isnt letting me create a data entry

I am having an issue when creating a new user in one of my tables.
My id is set as a cuid: id String @id @default(cuid()) ← from Prisma Schema

when creating a new entry on my table, i am getting an error for trying to create a new entry with a null id.

Given that the creation of the id is handled by the database itself, I expect forest admin to create the new data entry without any issue and allow the database to handle the id generation on its own

errror message: null value in column “id” of relation “Psychologist” violates not-null constraint


  • Project name: Zenith
  • Team name: Zenith
  • Environment name: Development
  • Agent (forest package) name & version: “@forestadmin/agent” : “^1.8.8”
  • Database type: SQL, PostgresSQL
  • Recent changes made on your end if any: this hasnt worked since the start

This is known, autogenerated ids need work on our side.
I’ll bump the priority of the ticket

Can you attempt to add the following code to your agent in the meantime?

agent.customizeCollection('user', users => {
  users.addHook('Before', 'Create', async (context) => { => {
1 Like

Hello, thank you for your reply.

I added the code however i am still not able to create a user, and it is giving me the same error

error: null value in column “id” of relation “Psychologist” violates not-null constraint

this is my collection currently

export const psychologistCollection = (
  collection: CollectionCustomizer<TSchema, "Psychologist">,
) => {
  collection.addHook("Before", "Create", async (context) => { => {

Hey @Albert_Geokgeuzian and welcome to our community :wave:

Could you confirm that the id entry is generated by your database and not by Prisma (By sharing the DDL of your table here/by DM if you consider it private)?

Could you also confirm that the id field is marked as read-only on your admin-panel side?

Thank you for your help. I had missed the fact that my ids are generated by Prisma and not the database. I will switch my ids to autoincremented.

You can create the ids in the hook

import { createId } from '@paralleldrive/cuid2';

agent.customizeCollection('user', users => {
  users.addHook('Before', 'Create', async (context) => { => { = createId();