Skip to content

Schema: parent_task_id, epic_id, base_branch, upstream_sha columns #55

@chanakyav

Description

@chanakyav

Parent Epic

Part of #52 — Sequential stacked PR chains

Summary

Add columns to the tasks table for task dependencies, chain grouping, stacked PR targeting, and upstream tracking. This is the data model that enables the chain command and cascade engine.

Context

Currently at schema v8. This bumps to v9 with four new nullable columns. All are additive (no breaking changes), handled by the existing migration system.

Changes

persistence.py

  • Bump SCHEMA_VERSION to 9
  • Add to SCHEMA (CREATE TABLE):
    • parent_task_id TEXT — FK to tasks.id, the task this one depends on (NULL = no parent)
    • epic_id TEXT — groups tasks into a chain (NULL = standalone task)
    • base_branch TEXT — PR target branch (NULL = use repo default branch)
    • upstream_sha TEXT — last-known HEAD SHA of the upstream branch when task started
  • Add migration entries to _MIGRATIONS:
    • (9, "tasks", "parent_task_id", "TEXT")
    • (9, "tasks", "epic_id", "TEXT")
    • (9, "tasks", "base_branch", "TEXT")
    • (9, "tasks", "upstream_sha", "TEXT")
  • Add all four to _TASK_COLUMNS frozenset
  • Add query helpers:
    • get_chain_tasks(epic_id) — SELECT tasks WHERE epic_id = ? ORDER BY created_at
    • get_dependent_tasks(task_id) — SELECT tasks WHERE parent_task_id = ?
    • get_parent_task(task_id) — get task record for the parent, if any
  • Update create_task() to accept optional parent_task_id, epic_id, base_branch

Depends On

Nothing — pure schema change, can be done first.

Testing

  • Create tasks with parent_task_id → get_parent_task() returns correct parent
  • Create tasks with epic_id → get_chain_tasks() returns all in order
  • get_dependent_tasks() returns correct dependents
  • Migration from v8 → v9 adds all four columns
  • NULL values work (backward compatible with existing tasks)
  • update_task() can set/update base_branch and upstream_sha
  • Update test_migration_from_pre_versioned_db to assert new columns

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions