workspace.sql.ts 627 B

12345678910111213141516171819202122
  1. import { 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. ...timestamps,
  11. },
  12. (table) => [uniqueIndex("slug").on(table.slug)],
  13. )
  14. export function workspaceIndexes(table: any) {
  15. return [
  16. primaryKey({
  17. columns: [table.workspaceID, table.id],
  18. }),
  19. ]
  20. }