2025-09-03 03:56:10 +00:00
|
|
|
import { mysqlTable, varchar, uniqueIndex, json } from "drizzle-orm/mysql-core"
|
2025-10-04 03:48:29 +00:00
|
|
|
import { timestamps, ulid, utc, workspaceColumns } from "../drizzle/types"
|
2025-08-08 17:22:54 +00:00
|
|
|
import { workspaceIndexes } from "./workspace.sql"
|
2025-09-03 03:56:10 +00:00
|
|
|
import { Actor } from "../actor"
|
2025-08-08 17:22:54 +00:00
|
|
|
|
2025-09-02 07:14:56 +00:00
|
|
|
export const KeyTable = mysqlTable(
|
2025-08-08 17:22:54 +00:00
|
|
|
"key",
|
|
|
|
|
{
|
|
|
|
|
...workspaceColumns,
|
|
|
|
|
...timestamps,
|
2025-09-03 03:56:10 +00:00
|
|
|
actor: json("actor").$type<Actor.Info>(),
|
2025-08-08 17:22:54 +00:00
|
|
|
name: varchar("name", { length: 255 }).notNull(),
|
2025-09-11 21:21:49 +00:00
|
|
|
oldName: varchar("old_name", { length: 255 }),
|
2025-08-08 17:22:54 +00:00
|
|
|
key: varchar("key", { length: 255 }).notNull(),
|
2025-10-04 03:48:29 +00:00
|
|
|
userID: ulid("user_id"),
|
2025-08-08 17:22:54 +00:00
|
|
|
timeUsed: utc("time_used"),
|
|
|
|
|
},
|
2025-10-04 03:48:29 +00:00
|
|
|
(table) => [...workspaceIndexes(table), uniqueIndex("global_key").on(table.key)],
|
2025-08-08 17:22:54 +00:00
|
|
|
)
|