UMBRA/backend/alembic/versions/002_add_subtasks.py
Kyle Pope ccfbf6df96 Add subtasks feature to project tasks
Backend:
- Add self-referencing parent_task_id FK on project_tasks with CASCADE delete
- Add Alembic migration 002 for parent_task_id column + index
- Update schemas with parent_task_id in create, nested subtasks in response
- Chain selectinload for subtasks on all project queries
- Validate parent must be top-level task (single nesting level only)

Frontend:
- Add parent_task_id and subtasks[] to ProjectTask type
- ProjectDetail: expand/collapse chevrons, subtask progress bars, inline
  subtask rendering with accent left border, add/edit/delete subtask buttons
- TaskForm: accept parentTaskId prop, include in create payload, context-aware
  dialog title (New Task vs New Subtask)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 01:31:46 +08:00

38 lines
1.1 KiB
Python

"""Add subtask support with parent_task_id
Revision ID: 002
Revises: 001
Create Date: 2026-02-15 00:00:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '002'
down_revision: Union[str, None] = '001'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.add_column('project_tasks', sa.Column('parent_task_id', sa.Integer(), nullable=True))
op.create_foreign_key(
'fk_project_tasks_parent_task_id',
'project_tasks',
'project_tasks',
['parent_task_id'],
['id'],
ondelete='CASCADE'
)
op.create_index('ix_project_tasks_parent_task_id', 'project_tasks', ['parent_task_id'])
def downgrade() -> None:
op.drop_index('ix_project_tasks_parent_task_id', table_name='project_tasks')
op.drop_constraint('fk_project_tasks_parent_task_id', 'project_tasks', type_='foreignkey')
op.drop_column('project_tasks', 'parent_task_id')