Nullable columns doesn't show up while doing inserts

This is my database schema

export const users = pgTable('users', {
  id: uuid('id').defaultRandom().primaryKey(),
  name: varchar('name', { length: 255 }).notNull(),
  email: varchar('email', { length: 255 }).notNull().unique(),
  password: varchar('password', { length: 255 }).notNull(),
  email_verified_at: timestamp('email_verified_at'),
  created_at: timestamp('created_at').defaultNow(),
  updated_at: timestamp('updated_at')
    .defaultNow()
    .$onUpdate(() => new Date()),
});

export const tokenTypes = pgEnum('token_types', [
  'EMAIL_VERIFICATION',
  'PASSWORD_RESET',
  'ORGANIZATION_INVITE',
]);

export const tokens = pgTable('tokens', {
  id: uuid('id').defaultRandom().primaryKey(),
  type: tokenTypes('type').notNull(),
  token: varchar('token', { length: 255 }).notNull().unique(),
  user_id: uuid('user_id').references(() => users.id, { onDelete: 'cascade' }),
  organization_id: uuid('organization_id').references(() => organizations.id),
  expires_at: timestamp('expires_at'),
});


When i try to do insert on any nullable fields it doesn't show up in insert types. Let's say while creating tokens user_id is nullable but i want to insert the user_id when creating token if i type user_id in values it shows typescript error. If i add .notNull() in the user_id foreign key it shows up in the insert.

does anyone has this issue?
Was this page helpful?