dow-prod-tracker/prisma
DJP 2c64356ffd Phase 3: Dow seed + rejection-routing automation
prisma/seed-dow.ts — idempotent seed for the Dow Jones tenant:
- Organization "Dow Jones" (dowjones.com)
- 6 ClientTeams: Brand, Events, B2B, Content, Briefing Team, Performance
- 3 placeholder Pods (Sergio, Deborah, Shared) — replace with real roster
  when it's available
- Dow Pipeline Template "Dow Jones Standard" with 11 stages:
  Pipeline → New → Copywriter → Client Review (Copy) → In Progress
  Creative → Internal Review → Client Feedback → Final Approval →
  Completed (+ On Hold, Canceled as terminal parking)
- Stage dependencies wired (optional stages bypass cleanly so
  In Progress Creative reaches from New when Copywriter is skipped)
- Automation rule "Client Feedback → reopen In Progress Creative":
  trigger on stage.status_changed where stageSlug=client-feedback and
  newStatus=CHANGES_REQUESTED. Actions: reopen sibling stage +
  increment revisionRound, send notification to assignee+producer.
- Initial admin user (DOW_ADMIN_EMAIL, default admin@dowjones.com)
  with bcrypt password and mustChangePassword=true. If
  DOW_ADMIN_PASSWORD env is unset a secure random is generated and
  logged once for handoff.
- RBAC defaults seeded per role including CLIENT_VIEWER.
- Legacy global PipelineStageTemplate rows seeded as FK scaffolding.

New action type "reopen_sibling_stage" in action-executor.ts:
- Given event.payload.deliverableId + params.siblingSlug, finds the
  sibling stage (matching either stageDefinition.slug or template.slug)
  and sets it to params.reopenStatus (default IN_PROGRESS). If
  params.incrementRound=true, bumps the stage's revisionRound counter
  and clears completedDate. Added to validateActions' allow-list.

Wiring:
- package.json db:seed → tsx prisma/seed-dow.ts (HP seed kept at
  db:seed-legacy for reference until deleted)
- prisma.config.ts migrations.seed → seed-dow.ts
- bcryptjs + @types/bcryptjs added

Verified: tsc --noEmit ✓ zero errors.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 18:53:20 -04:00
..
migrations Phase 1: Dow-customized Prisma schema + strip HP-only features 2026-04-20 18:35:14 -04:00
schema.prisma Phase 1: Dow-customized Prisma schema + strip HP-only features 2026-04-20 18:35:14 -04:00
seed-dow.ts Phase 3: Dow seed + rejection-routing automation 2026-04-20 18:53:20 -04:00
seed-tracker-data.ts feat: enhance UI components and add assignment feature to deliverables 2026-03-02 13:46:55 -06:00
seed.ts Database cleanup pre rollout 2026-04-06 14:35:56 -05:00