workspace.sql.ts 740 B

12345678910111213141516171819202122232425
  1. import { boolean, json, primaryKey, mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core"
  2. import { timestamps, ulid } from "../drizzle/types"
  3. export const WorkspaceTable = mysqlTable(
  4. "workspace",
  5. {
  6. id: ulid("id").notNull().primaryKey(),
  7. slug: varchar("slug", { length: 255 }),
  8. name: varchar("name", { length: 255 }).notNull(),
  9. region: json("region").$type<("us" | "eu" | "sg" | "cn")[]>(),
  10. is_blocked: boolean(),
  11. is_flagged_by_anthropic: boolean(),
  12. is_flagged_by_openai: boolean(),
  13. ...timestamps,
  14. },
  15. (table) => [uniqueIndex("slug").on(table.slug)],
  16. )
  17. export function workspaceIndexes(table: any) {
  18. return [
  19. primaryKey({
  20. columns: [table.workspaceID, table.id],
  21. }),
  22. ]
  23. }