mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-19 16:54:22 +01:00
27 lines
902 B
TypeScript
27 lines
902 B
TypeScript
import { mysqlTable, uniqueIndex, varchar, int, mysqlEnum } from "drizzle-orm/mysql-core"
|
|
import { timestamps, ulid, utc, workspaceColumns } from "../drizzle/types"
|
|
import { workspaceIndexes } from "./workspace.sql"
|
|
|
|
export const UserRole = ["admin", "member"] as const
|
|
|
|
export const UserTable = mysqlTable(
|
|
"user",
|
|
{
|
|
...workspaceColumns,
|
|
...timestamps,
|
|
accountID: ulid("account_id"),
|
|
oldAccountID: ulid("old_account_id"),
|
|
email: varchar("email", { length: 255 }),
|
|
oldEmail: varchar("old_email", { length: 255 }),
|
|
name: varchar("name", { length: 255 }).notNull(),
|
|
timeSeen: utc("time_seen"),
|
|
color: int("color"),
|
|
role: mysqlEnum("role", UserRole).notNull(),
|
|
},
|
|
(table) => [
|
|
...workspaceIndexes(table),
|
|
uniqueIndex("user_account_id").on(table.workspaceID, table.accountID),
|
|
uniqueIndex("user_email").on(table.workspaceID, table.email),
|
|
],
|
|
)
|