---
phase: 14-parallel-phase-execution
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
  - src/db/schema.ts
  - src/db/repositories/phase-repository.ts
  - src/db/repositories/drizzle/phase.ts
autonomous: true
---

<objective>
Add phase dependencies to database schema and repository following the task_dependencies pattern.

Purpose: Enable tracking which phases depend on which other phases, prerequisite for parallel execution.
Output: phase_dependencies table, PhaseRepository with dependency methods.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md

# Reference implementations:
@src/db/schema.ts
@src/db/repositories/task-repository.ts
@src/db/repositories/drizzle/task.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Add phase_dependencies table to schema</name>
  <files>src/db/schema.ts</files>
  <action>
Add phase_dependencies table mirroring task_dependencies:
- id (text, primary key)
- phaseId (text, FK to phases.id, cascade delete)
- dependsOnPhaseId (text, FK to phases.id, cascade delete)
- createdAt (integer timestamp)

Add relations for phases:
- dependsOn: many(phaseDependencies, relationName: 'dependentPhase')
- dependents: many(phaseDependencies, relationName: 'dependencyPhase')

Add phaseDependenciesRelations with:
- phase: one(phases, dependentPhase)
- dependsOnPhase: one(phases, dependencyPhase)

Export PhaseDependency and NewPhaseDependency types.
  </action>
  <verify>npx tsc --noEmit passes</verify>
  <done>phase_dependencies table defined with proper FK relations and types exported</done>
</task>

<task type="auto">
  <name>Task 2: Add dependency methods to PhaseRepository</name>
  <files>src/db/repositories/phase-repository.ts, src/db/repositories/drizzle/phase.ts</files>
  <action>
Add to PhaseRepository interface:
- createDependency(phaseId: string, dependsOnPhaseId: string): Promise<void>
- getDependencies(phaseId: string): Promise<string[]> (returns IDs of phases this phase depends on)
- getDependents(phaseId: string): Promise<string[]> (returns IDs of phases that depend on this phase)

Implement in DrizzlePhaseRepository:
- createDependency: insert into phase_dependencies with nanoid
- getDependencies: select dependsOnPhaseId where phaseId = input
- getDependents: select phaseId where dependsOnPhaseId = input

Follow exact patterns from DrizzleTaskRepository.createDependency.
  </action>
  <verify>npx tsc --noEmit passes; npm test -- --grep "phase" passes</verify>
  <done>PhaseRepository has dependency methods, Drizzle adapter implements them</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] `npm run build` succeeds without errors
- [ ] `npm test` passes all tests
- [ ] Phase dependency types exported from schema
- [ ] PhaseRepository interface has 3 new methods
- [ ] DrizzlePhaseRepository implements all methods
</verification>

<success_criteria>

- All tasks completed
- All verification checks pass
- Schema matches task_dependencies pattern
- Repository follows hexagonal architecture
</success_criteria>

<output>
After completion, create `.planning/phases/14-parallel-phase-execution/14-01-SUMMARY.md`
</output>
