Weird unique constraint
I'm trying to make a unique constraint on a column. It should also be case-insensitive (if there is one row with the value being "User", then "user" will be rejected) and allow non-distinct nulls. I can't figure out how to do this with drizzle-orm or sql. I appreciate any help. Thank you!
1 Reply
Hey @MyMainWasBanned. You can create unique index with
lower
expression
You can check this guide to learn how to do unique case insensitive column based on email
https://orm.drizzle.team/learn/guides/unique-case-insensitive-emailDrizzle ORM - Unique and Case-Insensitive Email Handling
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.