---
phase: 04-tasks-kanban
plan: "01"
subsystem: backend/tasks
tags: [migration, sqlc, tdd-red, css, sortablejs]
dependency_graph:
  requires: [03-tablos-crud/03-03]
  provides: [tasks-migration, tasks-sqlc, tasks-test-scaffold, sortablejs-asset, soft-danger-css]
  affects: [backend/internal/db/sqlc, backend/migrations, backend/templates, backend/static]
tech_stack:
  added: [SortableJS 1.15.7]
  patterns: [goose-migration, sqlc-queries, tdd-red-scaffold, css-utility-class]
key_files:
  created:
    - backend/migrations/0004_tasks.sql
    - backend/internal/db/queries/tasks.sql
    - backend/templates/tasks_forms.go
    - backend/internal/web/handlers_tasks_test.go
    - backend/static/sortable.min.js
  modified:
    - backend/justfile
    - backend/internal/web/ui/button.css
decisions:
  - "ENUM declaration order matches visual left-to-right column order (todo, in_progress, in_review, done) per Pitfall 6"
  - "Down migration drops tasks TABLE before task_status TYPE (Pitfall 3 — type is referenced by column)"
  - "All sqlc queries use explicit column lists (no SELECT *)"
  - "TasksDeps stub declared in test file — moved to handlers_tasks.go in Plan 02"
  - "t.Skip at top of each TestTask* function — all skip without running any DB setup"
metrics:
  duration: ~4min
  completed: "2026-05-15"
  tasks: 3
  files: 7
---

# Phase 4 Plan 01: Tasks Foundation (Wave 0) Summary

Wave 0 foundation for Tasks (Kanban): DB schema, sqlc query source, RED test scaffold, Sortable.js asset, soft-danger button CSS, and form structs. Nothing user-visible yet — creates preconditions for Plans 02 and 03 to deliver vertical slices.

## Tasks Completed

| Task | Name | Commit | Files |
|------|------|--------|-------|
| 1 | Migration 0004_tasks.sql + sqlc queries | c9c8262 | backend/migrations/0004_tasks.sql, backend/internal/db/queries/tasks.sql |
| 2 | RED test scaffold + form structs | 8b9543d | backend/internal/web/handlers_tasks_test.go, backend/templates/tasks_forms.go |
| 3 | Sortable.js bootstrap + soft-danger CSS | 55fb32f | backend/justfile, backend/internal/web/ui/button.css, backend/static/sortable.min.js |

## Verification Results

- `just migrate up` applied 0004_tasks.sql cleanly (goose 7.93ms, version 4)
- `just generate` produced TaskStatus type and Task struct in internal/db/sqlc/tasks.sql.go
- `go build ./...` exits 0
- `go test ./internal/web/ -run TestTask -v` exits 0 with 9 SKIP (TestTasksKanbanRenders, TestTaskCreate, TestTaskCreateValidation, TestTaskUpdate, TestTaskReorderCrossColumn, TestTaskReorderSameColumn, TestTaskDelete, TestTaskOrderPersists, TestTaskOwnership)
- `grep 'ui-button-soft-danger-md' button.css` returns match (3 occurrences — base, hover, focus-visible)
- `ls static/sortable.min.js` succeeds (45,478 bytes at 1.15.7)

## Decisions Made

1. **ENUM declaration order** matches visual left-to-right column order (`todo`, `in_progress`, `in_review`, `done`) per RESEARCH Pitfall 6 — ensures ENUM ordinal sorting aligns with kanban column display order.

2. **Down migration DROP order** — `DROP TABLE IF EXISTS tasks` precedes `DROP TYPE IF EXISTS task_status` per RESEARCH Pitfall 3 — the type cannot be dropped while referenced by a table column.

3. **TasksDeps stub in test file** — declared in `handlers_tasks_test.go` rather than a separate file so the test file compiles without requiring handlers_tasks.go to exist yet. Plan 02 moves it to handlers_tasks.go.

4. **t.Skip at top** of each TestTask* function — skips without executing any DB setup, so tests pass cleanly in environments without TEST_DATABASE_URL.

## Deviations from Plan

None — plan executed exactly as written.

## Known Stubs

None — this plan produces no UI-rendering code; all stubs are test-only t.Skip calls.

## Threat Flags

None — this plan adds no network endpoints, auth paths, file access patterns, or schema changes at trust boundaries beyond what is documented in the plan's threat model.

## Self-Check: PASSED

- backend/migrations/0004_tasks.sql: FOUND
- backend/internal/db/queries/tasks.sql: FOUND
- backend/templates/tasks_forms.go: FOUND
- backend/internal/web/handlers_tasks_test.go: FOUND
- backend/static/sortable.min.js: FOUND
- backend/justfile (sortable_version): FOUND
- backend/internal/web/ui/button.css (ui-button-soft-danger-md): FOUND
- Commits c9c8262, 8b9543d, 55fb32f: FOUND
