© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•16mo ago
ykisana

Conditional NotNull Column?

I have a 'users' table. User can have both phone number or email, or either, but both fields can't be null.
I tried adding the following constraint to my table:
sql "CHECK (email IS NOT NULL OR phone_number IS NOT NULL)"
sql "CHECK (email IS NOT NULL OR phone_number IS NOT NULL)"


But running into this issue on insert:
https://github.com/drizzle-team/drizzle-orm/issues/2694

Is there a better way to do this?
GitHub
[BUG]: Nullable columns do not exist in insert(table).values() · I...
What version of drizzle-orm are you using? 0.32.1 What version of drizzle-kit are you using? 0.23.0 Describe the Bug const files = pgTable("files", { id: uuid("id").primaryKey()...
[BUG]: Nullable columns do not exist in insert(table).values()  · I...
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

TypeError unless column is notNull
Drizzle TeamDTDrizzle Team / help
13mo ago
conditional columns
Drizzle TeamDTDrizzle Team / help
14mo ago
Migrations with new notNull() columns
Drizzle TeamDTDrizzle Team / help
3y ago
Can't alter column from `.notNull()` to `allow null`
Drizzle TeamDTDrizzle Team / help
2y ago