© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
9 replies
ansipedantic

Migrations with new notNull() columns

what's the proper way to add a notNull() column through a migration? I just tried to add a column in my schema like
  foo: text('foo').notNull()
  foo: text('foo').notNull()

and generated the migration with the standard
npx drizzle-kit generate:pg
npx drizzle-kit generate:pg
command

but during the
await migrate(...) 
await migrate(...) 
call, I get an error that existing rows have a NULL value (which, yes... i'm just adding the column now). I don't see anything in the docs about customizing migrations to backfill existing rows in cases like this. Is there a way to properly handle this?
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

Migrations not changing on adding notNull
Drizzle TeamDTDrizzle Team / help
2y ago
Conditional NotNull Column?
Drizzle TeamDTDrizzle Team / help
16mo ago
PgColumnBuilderBase and notNull()
Drizzle TeamDTDrizzle Team / help
17mo ago
notNull and Unique
Drizzle TeamDTDrizzle Team / help
2y ago