EspadaV8
EspadaV8
KKysely
Created by EspadaV8 on 1/3/2024 in #help
"Correct" way to create a unique index with some raw SQL
I'm attempting to create a new unique index on a username column, but I want it to be unique on LOWER(username). I have the following, and it works, but I was wondering if there is an alternative way to do this without having it all as a raw query?
await sql`CREATE UNIQUE INDEX users_unique_username_idx ON users (LOWER(username));`.execute(
db,
);
await sql`CREATE UNIQUE INDEX users_unique_username_idx ON users (LOWER(username));`.execute(
db,
);
17 replies