Files
state-hub/migrations/versions/h5c6d7e8f9a0_suggestion_workflow.py
tegwick 1f1da56533 feat(suggestions): full suggestion workflow with per-step notes
DB migration h5c6d7e8f9a0:
- Extends tdstatus enum: submitted → analyse → plan → implement →
  test → review → finished (+ wont_fix remains)
- New td_notes table: td_id FK (CASCADE), step, author, content, created_at

API:
- TDNote model + TDNoteCreate/TDNoteRead schemas
- TDRead includes notes[] (selectin loaded)
- New routes: GET/POST /technical-debt/{id}/notes/
- list_td status filter accepts str (all enum values)

Modal: new submissions use status="submitted" instead of "open"

UI Feedback page revamp:
- Visual step-by-step stepper (submitted→analyse→plan→implement→test→review→finished)
- Per-step notes: view all notes, add note inline
- Action buttons: advance to next step, won't fix
- Review step highlighted as awaiting original suggester confirmation
- Closed items (finished/wont_fix) shown with last 2 notes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 00:57:34 +01:00

43 lines
1.5 KiB
Python

"""suggestion workflow: extend tdstatus enum + td_notes table
Revision ID: h5c6d7e8f9a0
Revises: g4b5c6d7e8f9
Create Date: 2026-03-18
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = "h5c6d7e8f9a0"
down_revision = "g4b5c6d7e8f9"
branch_labels = None
depends_on = None
def upgrade() -> None:
# Extend tdstatus enum with workflow step values.
# IF NOT EXISTS prevents errors on re-runs; values cannot be removed in downgrade.
for val in ("submitted", "analyse", "plan", "implement", "test", "review", "finished"):
op.execute(f"ALTER TYPE tdstatus ADD VALUE IF NOT EXISTS '{val}'")
# Per-step notes for technical debt items (used by dashboard-improvement workflow)
op.create_table(
"td_notes",
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True,
server_default=sa.text("gen_random_uuid()")),
sa.Column("td_id", postgresql.UUID(as_uuid=True),
sa.ForeignKey("technical_debt.id", ondelete="CASCADE"),
nullable=False, index=True),
sa.Column("step", sa.String(30), nullable=False),
sa.Column("author", sa.String(100), nullable=True),
sa.Column("content", sa.Text, nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True),
server_default=sa.text("now()"), nullable=False),
)
def downgrade() -> None:
op.drop_table("td_notes")
# Note: PostgreSQL does not support removing enum values;
# the added tdstatus values remain after downgrade.