Skip to content

fix(prisma): add grooming run migration#471

Merged
joryirving merged 1 commit into
mainfrom
fix/470-grooming-run-migration
Jun 28, 2026
Merged

fix(prisma): add grooming run migration#471
joryirving merged 1 commit into
mainfrom
fix/470-grooming-run-migration

Conversation

@joryirving

Copy link
Copy Markdown
Contributor

Adds the missing Prisma migration for GroomingRun, so prisma migrate deploy creates the table used by the groomer history API and hosted groomer writes. Also tracks Prisma's migration lock file and ignores local .worktrees/ directories.

Closes #470

Verified:

  • DATABASE_URL="postgresql://user:pass@localhost:5432/dispatch" npx prisma validate
  • npm run typecheck
  • npm run lint
  • npm test -- src/lib/groomer/history.test.ts src/app/api/groomer/runs/route.test.ts 'src/app/api/groomer/runs/[id]/route.test.ts'

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Automated Review

Full PR review.

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic) — routed smart (risk match: db_or_migration_changes)

PR Review: fix(prisma): add grooming run migration (PR 471)

Recommendation: Approve

This PR adds the missing Prisma migration for the GroomingRun model that was introduced in PR 468 but never shipped with a migration. The migration is safe, correct, and all required CI checks pass.


Change-by-Change Analysis

1. prisma/migrations/20260628000000_add_grooming_run/migration.sql

A new table GroomingRun is created with the following structure:

  • Core columns: id, issueId, repoId, agentRunId, repoFullName, issueNumber, issueUrl, status, dryRun
  • Groomer configuration: candidateSource, stage, model, provider, promptVersion, timeoutMs, maxContextBytes
  • JSON/array fields: contextSummary, contextWarnings, rawOutput, validatedOutput, validationErrors, labelsBefore, labelsAfter, labelsToAdd, labelsToRemove, mutationPlan, appliedMutations
  • Audit/metadata: laneBefore, laneAfter, commentBodyPreview, commentUrl, errorMessage, retryable, startedAt, completedAt, createdAt, updatedAt

Foreign key constraints are properly defined:

  • issueIdIssue(id) with ON DELETE CASCADE
  • repoIdAutomationRepo(id) with ON DELETE CASCADE
  • agentRunIdAgentRun(id) with ON DELETE SET NULL

Nine indexes cover common query patterns including compound indexes for issueId+createdAt, repoId+status+createdAt, and issueId+status.

2. prisma/migrations/migration_lock.toml

Lock file specifies provider = "postgresql" as expected for this project.

3. .gitignore

Adds .worktrees/ to ignore local git worktree directories (hygiene change).


Required Check Results

✅ Review migration for data loss risk

Verified: This migration is a pure CREATE TABLE operation with no destructive operations (no DROP, ALTER to remove columns, or data transformations). The GroomingRun table did not previously exist, so no data can be lost. Foreign keys use CASCADE for parent deletions which is intentional (when an Issue or AutomationRepo is deleted, its grooming runs should be cleaned up). The agentRunId FK uses SET NULL appropriately since an AgentRun may be deleted independently.

⚠️ Test migration on a copy of production schema

Not verifiable from PR diff: I cannot execute migrations against a production schema copy from this review. However:

  • CI checks (Build, Lint, Typecheck, Tests, Docker Build) all pass successfully
  • The PR author verified npx prisma validate and ran the relevant test suite
  • The migration is syntactically correct PostgreSQL DDL
  • The schema was validated against the existing schema.prisma model

Standards Compliance

Standard Status
Prisma conventions ✅ Migration follows Prisma v7 format with _migration_lock.toml
PostgreSQL syntax ✅ Uses valid PostgreSQL DDL
No secrets committed ✅ No secrets in diff
Code standards ✅ Clean migration with proper constraints and indexes

Linked Issue Fit

Issue PR 470 described that:

  • GroomingRun model was added in PR 468 without a migration
  • /api/groomer/runs and /api/groomer/runs/[id] return HTTP 500
  • Impact: History API broken, /automation/groomer UI broken

This PR directly addresses the issue by adding the missing migration file. The SQL creates exactly the table structure expected by the model. Issue acceptance criteria are satisfied.


Evidence Provider Findings

No evidence providers configured for this review.


Tool Harness Findings

No tool calls were issued; reviewing corpus directly.


Unknowns / Needs Verification

  1. Production schema testing: Cannot verify from this PR diff. Recommend running prisma migrate deploy --dry-run or testing on a staging environment before production deployment.
  2. Schema completeness: The diff shows only the migration SQL. I cannot verify the full GroomingRun model definition in schema.prisma from this PR, but given the migration matches the described schema structure and the author verified with prisma validate, this is low risk.

Conclusion

This is a straightforward, safe migration that adds a new table to fix a broken feature. No data loss risk exists (new table creation only). CI passes. The fix directly addresses the linked issue. Approve for merge.

@joryirving joryirving merged commit 72ef5ff into main Jun 28, 2026
6 checks passed
@joryirving joryirving deleted the fix/470-grooming-run-migration branch June 28, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GroomingRun model added in #468 without Prisma migration — /api/groomer/runs returns 500

1 participant