1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import { mysqlTable, uniqueIndex, varchar, int, mysqlEnum } from "drizzle-orm/mysql-core"
import { timestamps, utc, workspaceColumns } from "../drizzle/types"
import { workspaceIndexes } from "./workspace.sql"
const UserRole = ["admin", "member"] as const
export type UserRole = (typeof UserRole)[number]
export const UserTable = mysqlTable(
"user",
{
...workspaceColumns,
...timestamps,
email: varchar("email", { length: 255 }).notNull(),
name: varchar("name", { length: 255 }).notNull(),
timeSeen: utc("time_seen"),
timeJoined: utc("time_joined"),
color: int("color"),
role: mysqlEnum("role", ["admin", "member"]).notNull(),
},
(table) => [...workspaceIndexes(table), uniqueIndex("user_email").on(table.workspaceID, table.email)],
)
|