© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
1 reply
firxworx

Are postgres CONSTRAINTS supported when creating a table schema?

In the column builder types I see there's a general assumption of
name
name
,
dataType
dataType
,
columnType
columnType
.

In contrast the actual Postgres CREATE TABLE syntax is very rich:

https://www.postgresql.org/docs/current/sql-createtable.html

Are there ways to support column constraints, table constraints, etc?

If a dev has requirements not yet supported by Drizzle, it appears from the docs the use-case is understood (much appreciated!) and the
sql
sql
template exists for that.

However I don't think that
sql
sql
is supported for generating table schemas or that we can use it with custom type definitions?

Is there a way I can still use drizzle schemas and migrations if I need to override some of the generated output to meet the requirements of my schema?

If custom types enabled adding constraints that would be really helpful.

Its like I can almost do it: if I make a
customType()
customType()
definition return anything other than a one-word string when specifying
dataType
dataType
the generated SQL encapsulates the entire value in double quotes. If it didn't do that, I would be able to return a string that included my type and constraints and be off to the races.

That's probably a bit of a hack but it shows a potential path to supporting column constraints: as a property that can be specified when defining a custom type (if they're not already supported and I just don't know how and can't find any docs on it).
PostgreSQL Documentation
CREATE TABLE
CREATE TABLE CREATE TABLE — define a new table Synopsis CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | …
CREATE TABLE
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Programmatically pull table schema (Postgres)
Drizzle TeamDTDrizzle Team / help
2mo ago
pgTableCreator on creating constraints
Drizzle TeamDTDrizzle Team / help
11mo ago
PostgresError: unrecognized configuration parameter "schema" when creating client for postgres-js
Drizzle TeamDTDrizzle Team / help
3y ago
push:pg not creating table schema (pgSchema)
Drizzle TeamDTDrizzle Team / help
3y ago