© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
3 replies
Paul

How to create unique lowercase index?

I'm trying to recreate the following sql statement. I don't think what I'm writing with the where clause is correct.
But writing
.on(sql
.on(sql
lower(domain)
)
)
results in a type error. Is there a way to do it in drizzle currently?

create unique index sso_domains_domain_idx on auth.sso_domains using btree (lower(domain)) tablespace pg_default;
create unique index sso_domains_domain_idx on auth.sso_domains using btree (lower(domain)) tablespace pg_default;


export const ssoDomains = authSchema.table(
  "sso_domains",
    {
      domain: text("domain").notNull(),
    },
    table => ({
      ssoDomainsDomainIdx: uniqueIndex("sso_domains_domain_idx").on(table.domain).where(sql`lower(${table.domain.name})`),
    })
);
export const ssoDomains = authSchema.table(
  "sso_domains",
    {
      domain: text("domain").notNull(),
    },
    table => ({
      ssoDomainsDomainIdx: uniqueIndex("sso_domains_domain_idx").on(table.domain).where(sql`lower(${table.domain.name})`),
    })
);
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

How to create two-way unique index or constraint
Drizzle TeamDTDrizzle Team / help
2y ago
Set unique index length
Drizzle TeamDTDrizzle Team / help
3y ago
drizzle-kit and unique index
Drizzle TeamDTDrizzle Team / help
4w ago
push:mysql dropping unique index
Drizzle TeamDTDrizzle Team / help
3y ago