summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core/src/schema/key.sql.ts
blob: 892c74686b6e9dc6e1de756b09540e93ec0f6e66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { mysqlTable, varchar, uniqueIndex, json } from "drizzle-orm/mysql-core"
import { timestamps, ulid, utc, workspaceColumns } from "../drizzle/types"
import { workspaceIndexes } from "./workspace.sql"
import { Actor } from "../actor"

export const KeyTable = mysqlTable(
  "key",
  {
    ...workspaceColumns,
    ...timestamps,
    actor: json("actor").$type<Actor.Info>(),
    name: varchar("name", { length: 255 }).notNull(),
    oldName: varchar("old_name", { length: 255 }),
    key: varchar("key", { length: 255 }).notNull(),
    userID: ulid("user_id"),
    timeUsed: utc("time_used"),
  },
  (table) => [...workspaceIndexes(table), uniqueIndex("global_key").on(table.key)],
)