CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
schema-deploys.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| f764c07 | 1 | /** |
| 9dd96b9 | 2 | * Block N3 + R2 — Drizzle schema for the platform-deploy timeline. |
| f764c07 | 3 | * |
| 4 | * Defined in a SEPARATE module because `src/db/schema.ts` is listed in | |
| 5 | * §4 LOCKED BLOCKS of BUILD_BIBLE.md ("New tables only via new migration"). | |
| 9dd96b9 | 6 | * The matching migrations are |
| 7 | * - `drizzle/0046_platform_deploys.sql` (Block N3) | |
| 8 | * - `drizzle/0053_deploy_steps.sql` (Block R2 — `last_step`, `step_count`, | |
| 9 | * `platform_deploy_steps`) | |
| f764c07 | 10 | * |
| 11 | * Columns mirror the SQL migration 1:1 — keep in sync when superseded by a | |
| 12 | * follow-up additive migration. | |
| 13 | */ | |
| 14 | ||
| 15 | import { | |
| 16 | index, | |
| 17 | integer, | |
| 18 | pgTable, | |
| 19 | text, | |
| 20 | timestamp, | |
| 21 | uuid, | |
| 22 | } from "drizzle-orm/pg-core"; | |
| 23 | ||
| 24 | export const platformDeploys = pgTable( | |
| 25 | "platform_deploys", | |
| 26 | { | |
| 27 | id: uuid("id").primaryKey().defaultRandom(), | |
| 28 | runId: text("run_id").notNull().unique(), | |
| 29 | sha: text("sha").notNull(), | |
| 30 | source: text("source").notNull(), | |
| 31 | // 'in_progress' | 'succeeded' | 'failed' | |
| 32 | status: text("status").notNull().default("in_progress"), | |
| 33 | startedAt: timestamp("started_at", { withTimezone: true }) | |
| 34 | .defaultNow() | |
| 35 | .notNull(), | |
| 36 | finishedAt: timestamp("finished_at", { withTimezone: true }), | |
| 37 | durationMs: integer("duration_ms"), | |
| 38 | error: text("error"), | |
| 39 | createdAt: timestamp("created_at", { withTimezone: true }) | |
| 40 | .defaultNow() | |
| 41 | .notNull(), | |
| 9dd96b9 | 42 | // R2 — latest step the deploy reached + running count. Both populated by |
| 43 | // POST /api/events/deploy/step so a page refresh mid-deploy still shows | |
| 44 | // the last known position even before SSE re-attaches. | |
| 45 | lastStep: text("last_step"), | |
| 46 | stepCount: integer("step_count").notNull().default(0), | |
| f764c07 | 47 | }, |
| 48 | (table) => [index("idx_platform_deploys_started").on(table.startedAt)] | |
| 49 | ); | |
| 50 | ||
| 51 | export type PlatformDeployRow = typeof platformDeploys.$inferSelect; | |
| 52 | export type NewPlatformDeployRow = typeof platformDeploys.$inferInsert; | |
| 9dd96b9 | 53 | |
| 54 | // R2 — per-step audit trail. Optional surface; SSE is the live channel but | |
| 55 | // rows here let `/admin/deploys` reconstruct an in-progress deploy on | |
| 56 | // reload. The (deploy_id, step_name, status) tuple is uniquely indexed (see | |
| 57 | // migration 0053) so re-POSTing a step is a no-op. | |
| 58 | export const platformDeploySteps = pgTable( | |
| 59 | "platform_deploy_steps", | |
| 60 | { | |
| 61 | id: uuid("id").primaryKey().defaultRandom(), | |
| 62 | deployId: uuid("deploy_id").notNull(), | |
| 63 | stepName: text("step_name").notNull(), | |
| 64 | // 'in_progress' | 'succeeded' | 'failed' | |
| 65 | status: text("status").notNull(), | |
| 66 | startedAt: timestamp("started_at", { withTimezone: true }) | |
| 67 | .defaultNow() | |
| 68 | .notNull(), | |
| 69 | finishedAt: timestamp("finished_at", { withTimezone: true }), | |
| 70 | durationMs: integer("duration_ms"), | |
| 71 | output: text("output"), | |
| 72 | createdAt: timestamp("created_at", { withTimezone: true }) | |
| 73 | .defaultNow() | |
| 74 | .notNull(), | |
| 75 | }, | |
| 76 | (table) => [ | |
| 77 | index("idx_platform_deploy_steps_deploy").on( | |
| 78 | table.deployId, | |
| 79 | table.startedAt | |
| 80 | ), | |
| 81 | ] | |
| 82 | ); | |
| 83 | ||
| 84 | export type PlatformDeployStepRow = typeof platformDeploySteps.$inferSelect; | |
| 85 | export type NewPlatformDeployStepRow = | |
| 86 | typeof platformDeploySteps.$inferInsert; |