61 lines
1.8 KiB
Markdown
61 lines
1.8 KiB
Markdown
|
|
---
|
||
|
|
kind: task
|
||
|
|
slug: db-model-providers-migration
|
||
|
|
title: Drizzle schema and migration for model_providers and role_model_routes
|
||
|
|
plan_slug: automation-foundation
|
||
|
|
epic_slug: model-provider-registry
|
||
|
|
status: ready
|
||
|
|
priority: P1
|
||
|
|
tenant_id: global
|
||
|
|
owner: unassigned
|
||
|
|
cursor_todo_id: null
|
||
|
|
updated_at: "2026-07-03"
|
||
|
|
agent_prompt: |
|
||
|
|
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
|
||
|
|
|
||
|
|
## Links
|
||
|
|
|
||
|
|
- Epic: `./Epic-model-provider-registry.md`
|
||
|
|
- ADR: `../../../docs/adr-model-routing.md`
|
||
|
|
- Depends on: `Task-shared-schemas-resolve-model.md`
|