drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: Allow `Check` Constraint on Column Instead of at the End of Table
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
According to the documentation, the only way to add a `check` constraint is at the end of the table definition. However, I would prefer to have column check constraints next to the column name, similar to `.unique()`, `.notNull()`, etc. Is there a way to do so?
Documentation: https://orm.drizzle.team/docs/indexes-constraints#check
```
const emailsTable = pgTable(
"emails",
{
id: uuid().primaryKey(),
email_status: text({ enum: ["pending", "sent", "canceled"] }).notNull(),
},
(table) => {
return [
check(
"email_status_type",
sql`${table.email_status} IN ('pending', 'sent', 'canceled')`
)
];
}
);
```
Contributor guide
Assessment
This issue has not been assessed yet.