schema unique case insensitive
Suppose I have a table Clients and I want the name to be unique.
But, I want it to be case insensivive, normally I would use
COLLATE NOCASE
, but I couldn't find how to do that in drizzle.
Would love some help please.
Using sqlite.7 Replies
You can use something like this for selecting:
I think this might work as well:
For testing and debugging you can pass
logger: true
to drizzle.
For creating the table you can define the tables and the generate a migration.
Then you can edit the migration to add the COLLATE NOCASE
so that the migration will create it correctly.But I'm not selecting, I'm creating a schema and I want to use the tools sql gives me.
My question is how
Drizzle doesn't support this natively. You could hack it by passing a sql argument to the default and all of that at the end
On your column definition:
You might need to do some testing to see if that gives you what you want, I haven't test it
You can edit the generated migration sql if you want to create tables with collate nocase.
It worked man! Thanks!
@Angelelz Is there a way to make every "string" column in a table behave case-insensitive on any unique check, other than appending each column with
.default(sql 'collate nocase')
?nevermind, found the answer here: https://github.com/drizzle-team/drizzle-orm/discussions/123
GitHub
Does it support postgres extensions? · drizzle-team drizzle-orm · D...
I am most interested in CITEXT and POSTGIS. Is there a way to work with those?