generated from coulomb/repo-seed
- Migration c5d6e7f8a9b0: domain_goals and repo_goals tables, repo_goal_id FK on workstreams - DomainGoal: one active per domain (partial unique index), status active/archived/superseded - RepoGoal: integer priority, status active/paused/completed/archived, optional domain_goal_id link - WorkstreamUpdate schema and router extended with repo_goal_id and repo_goal_id filter - 6 new MCP goal tools: create_domain_goal, get_domain_goals, activate_domain_goal, create_repo_goal, get_repo_goals, update_repo_goal - update_workstream MCP tool: patch any subset of workstream fields (title, description, owner, due_date, repo_goal_id, status) - get_domain_summary extended with goal_guidance (needs_workplan, alignment_warnings) signals - Dashboard goals.md page and docs/goals.md reference page - CLAUDE.md template updated to act on goal_guidance signals at session start - CUST-WP-0010 workplan for this feature Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
86 lines
3.9 KiB
Python
86 lines
3.9 KiB
Python
"""Add domain_goals and repo_goals; add repo_goal_id FK to workstreams
|
|
|
|
Revision ID: c5d6e7f8a9b0
|
|
Revises: b4c5d6e7f8a9
|
|
Create Date: 2026-03-08 00:00:00.000000
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
revision: str = "c5d6e7f8a9b0"
|
|
down_revision: Union[str, None] = "b4c5d6e7f8a9"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"domain_goals",
|
|
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column("domain_id", postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column("title", sa.String(500), nullable=False),
|
|
sa.Column("description", sa.Text(), nullable=False),
|
|
sa.Column("status", sa.String(20), nullable=False, server_default="active"),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), nullable=False),
|
|
sa.ForeignKeyConstraint(["domain_id"], ["domains.id"], ondelete="RESTRICT"),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index("ix_domain_goals_domain_id", "domain_goals", ["domain_id"])
|
|
op.create_index("ix_domain_goals_status", "domain_goals", ["status"])
|
|
# Partial unique index: only one active goal per domain at a time
|
|
op.execute(
|
|
"CREATE UNIQUE INDEX ix_domain_goals_one_active "
|
|
"ON domain_goals (domain_id) WHERE status = 'active'"
|
|
)
|
|
|
|
op.create_table(
|
|
"repo_goals",
|
|
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column("repo_id", postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column("domain_goal_id", postgresql.UUID(as_uuid=True), nullable=True),
|
|
sa.Column("title", sa.String(500), nullable=False),
|
|
sa.Column("description", sa.Text(), nullable=False),
|
|
sa.Column("priority", sa.Integer(), nullable=False, server_default="100"),
|
|
sa.Column("status", sa.String(20), nullable=False, server_default="active"),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), nullable=False),
|
|
sa.ForeignKeyConstraint(["repo_id"], ["managed_repos.id"], ondelete="RESTRICT"),
|
|
sa.ForeignKeyConstraint(["domain_goal_id"], ["domain_goals.id"], ondelete="SET NULL"),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index("ix_repo_goals_repo_id", "repo_goals", ["repo_id"])
|
|
op.create_index("ix_repo_goals_domain_goal_id", "repo_goals", ["domain_goal_id"])
|
|
op.create_index("ix_repo_goals_status", "repo_goals", ["status"])
|
|
op.create_index("ix_repo_goals_priority", "repo_goals", ["priority"])
|
|
|
|
op.add_column(
|
|
"workstreams",
|
|
sa.Column(
|
|
"repo_goal_id",
|
|
postgresql.UUID(as_uuid=True),
|
|
sa.ForeignKey("repo_goals.id", ondelete="SET NULL"),
|
|
nullable=True,
|
|
),
|
|
)
|
|
op.create_index("ix_workstreams_repo_goal_id", "workstreams", ["repo_goal_id"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_workstreams_repo_goal_id", table_name="workstreams")
|
|
op.drop_column("workstreams", "repo_goal_id")
|
|
|
|
op.drop_index("ix_repo_goals_priority", table_name="repo_goals")
|
|
op.drop_index("ix_repo_goals_status", table_name="repo_goals")
|
|
op.drop_index("ix_repo_goals_domain_goal_id", table_name="repo_goals")
|
|
op.drop_index("ix_repo_goals_repo_id", table_name="repo_goals")
|
|
op.drop_table("repo_goals")
|
|
|
|
op.execute("DROP INDEX IF EXISTS ix_domain_goals_one_active")
|
|
op.drop_index("ix_domain_goals_status", table_name="domain_goals")
|
|
op.drop_index("ix_domain_goals_domain_id", table_name="domain_goals")
|
|
op.drop_table("domain_goals")
|