workspace.sql.ts 554 B

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