File
Blob: src/worker/db/d1/schema/projects.ts
| 1 | import { desc } from "drizzle-orm"; |
| 2 | import { index, integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core"; |
| 3 | |
| 4 | export const projectIndex = sqliteTable( |
| 5 | "project_index", |
| 6 | { |
| 7 | id: text("id").primaryKey(), |
| 8 | ownerUserId: text("owner_user_id").notNull(), |
| 9 | ownerSlug: text("owner_slug").notNull(), |
| 10 | projectSlug: text("project_slug").notNull(), |
| 11 | name: text("name").notNull(), |
| 12 | repoUrl: text("repo_url").notNull(), |
| 13 | defaultBranch: text("default_branch").notNull(), |
| 14 | configPath: text("config_path").notNull(), |
| 15 | createdAt: integer("created_at").notNull(), |
| 16 | updatedAt: integer("updated_at").notNull(), |
| 17 | }, |
| 18 | (table) => [ |
| 19 | uniqueIndex("idx_project_index_owner_project_slug").on(table.ownerSlug, table.projectSlug), |
| 20 | index("idx_project_index_owner_user_updated_at").on(table.ownerUserId, desc(table.updatedAt)), |
| 21 | index("idx_project_index_updated_at").on(desc(table.updatedAt)), |
| 22 | ], |
| 23 | ); |