How do I set a column to be unique in drizzle syntax for mySQL?

Would something like this be correct?
export const authUsers = mysqlTable(
'auth_users',
{
id: varchar('id', { length: 191 }).primaryKey().notNull(),
username: varchar('username', { length: 191 }).notNull()
},
(table) => {
return {
idKey: uniqueIndex('auth_users_id_key').on(table.id),
usernameKey: uniqueIndex('auth_users_username_key').on(table.username)
};
}
);
export const authUsers = mysqlTable(
'auth_users',
{
id: varchar('id', { length: 191 }).primaryKey().notNull(),
username: varchar('username', { length: 191 }).notNull()
},
(table) => {
return {
idKey: uniqueIndex('auth_users_id_key').on(table.id),
usernameKey: uniqueIndex('auth_users_username_key').on(table.username)
};
}
);
wishing there was a .unique()
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cory
CoryOP2y ago
ah okay cool!
Want results from more Discord servers?
Add your server