defaultFn not nullable

I have this schema:

export const userTableSchema = pgTable(
  "user",
  {
    id: text("id")
      .$defaultFn(() => createId())
      .primaryKey()
      .notNull(),
    createdAt: timestamp("created_at", {
      withTimezone: true,
      mode: "date",
    }).notNull(),
    confirmedEmail: boolean("confirmed_email")
      .notNull()
      .$default(() => false),
    confirmedPhone: boolean("confirmed_phone")
      .notNull()
      .$default(() => false),
    name: varchar("name", { length: 255 }).notNull(),
    email: varchar("email", { length: 255 }).notNull(),
  },
  (table) => {
    return {
      emailIdx: uniqueIndex("users_email_idx").on(table.email),
    }
  }
)


when I set .$defaultFn(() => createId()) for the Id property it marks it as Optional:

Is that a way to change that behavior and make it not nullable?
image.png
Was this page helpful?