Submatter/plans/Plan-automation-foundation/Epic-model-provider-registry/Task-db-model-providers-migration.md
Randall Stillwell e256380671 plan(automation): add mission-control foundation backlog and model-routing ADR
Documents the automation foundation plan (nine epics, Epic 1 taskified) and
the accepted model-provider registry contract. Updates .env.example for backlog
import workspace id and local/cloud AI provider env guidance.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 13:55:03 -05:00

1.8 KiB

kind slug title plan_slug epic_slug status priority tenant_id owner cursor_todo_id updated_at agent_prompt
task db-model-providers-migration Drizzle schema and migration for model_providers and role_model_routes automation-foundation model-provider-registry ready P1 global unassigned null 2026-07-03 Read docs/adr-model-routing.md and packages/shared model-routing types from Task-shared-schemas-resolve-model. packages/database only. Generate migration with pnpm db:generate — do not hand-edit SQL. claim_task before work.

Task summary

Add model_providers and role_model_routes tables with workspace scoping and indexes per the ADR.

Description

Schema (packages/database/src/schema/)

  • model_providers.ts — columns from ADR; unique (workspace_id, alias)
  • role_model_routes.ts — FK to model_providers; unique (workspace_id, role_id)
  • Re-export from schema/index.ts; add relations if needed

Migration

  • pnpm db:generate from repo root after schema edit
  • Commit generated SQL under packages/database/migrations/

Optional seed helper

  • seedDefaultRoleRoutes(workspaceId) in database package or web server — inserts pipeline default role_ids pointing at aliases only if matching aliases exist (no auto-create of providers)

Subtasks

  • Define Drizzle tables
  • Generate and commit migration
  • Verify workspace_id index on both tables

Estimation

S

Acceptance criteria

  • Migration applies cleanly with pnpm db:migrate
  • Every query example in epic doc filters by workspace_id
  • Types align with packages/shared zod schemas
  • Epic: ./Epic-model-provider-registry.md
  • ADR: ../../../docs/adr-model-routing.md
  • Depends on: Task-shared-schemas-resolve-model.md