summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core/src/schema/auth.sql.ts
blob: be2244ef312adc5f4c102cebd96ea6a72b7aeccb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { mysqlEnum, mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core"
import { id, timestamps, ulid } from "../drizzle/types"

export const AuthProvider = ["email", "github", "google"] as const

export const AuthTable = mysqlTable(
  "auth",
  {
    id: id(),
    ...timestamps,
    provider: mysqlEnum("provider", AuthProvider).notNull(),
    subject: varchar("subject", { length: 255 }).notNull(),
    accountID: ulid("account_id").notNull(),
  },
  (table) => [uniqueIndex("provider").on(table.provider, table.subject)],
)