© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
2 replies
Icemourne

How can I make reusable columns then building schema?

If I save part of column in variable
const username = varchar('username', { length: 30 }).unique().notNull()
const username = varchar('username', { length: 30 }).unique().notNull()

and then add something
const username_reference = username.references(() => userSchema.username, { onUpdate: 'cascade' })
const username_reference = username.references(() => userSchema.username, { onUpdate: 'cascade' })

It will change first one to
It changes objects properties instead of making copy and that's reasonable but I need to make copy and can't figure out how
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

Schema building
Drizzle TeamDTDrizzle Team / help
15mo ago
How to handle adding new columns to schema?
Drizzle TeamDTDrizzle Team / help
3y ago
How can I accomplish this in a schema?
Drizzle TeamDTDrizzle Team / help
3y ago
How can I make my Postgres schema automatically insert `UTC` time when using `defaultNow()`?
Drizzle TeamDTDrizzle Team / help
2y ago