© 2026 Hedgehog Software, LLC
.on(lower(table.email))
import { SQL, sql } from "drizzle-orm"; import { AnyPgColumn, pgTable, timestamp, uniqueIndex, uuid, varchar, } from "drizzle-orm/pg-core"; export const users = pgTable( "users", { id: uuid("id").defaultRandom().notNull().primaryKey(), email: varchar("email", { length: 256 }).notNull(), username: varchar("username", { length: 16 }).notNull(), displayname: varchar("displayname", { length: 32 }).notNull(), created_at: timestamp("created_at", { mode: "date" }).notNull(), }, (table) => ({ emailUniqueIndex: uniqueIndex("emailUniqueIndex").on(lower(table.email)), usernameUniqueIndex: uniqueIndex("usernameUniqueIndex").on(lower(table.username)) }), ); export function lower(email: AnyPgColumn): SQL { return sql`lower(${email})`; }