feat: add backend support for hierarchical subtasks

- Create migration 005 to add parent_id and level columns to todos tables
- Fix migration 003 to use correct table name (note_todos instead of todos)
- Update POST /api/notes/:id/todos to accept parent_id parameter
- Update POST /api/todos to accept parent_id for global todos
- Add automatic level calculation based on parent depth
- Update GET endpoints to return parent_id and level fields
- Add validation to ensure parent todo exists before creating subtask
- Support CASCADE DELETE for subtasks when parent is deleted
This commit is contained in:
Claude committed 2025-11-27 13:51:42 +00:00
1 parent a1addbacba
commit bde406bc3e
4 files changed
+71 -25

No files matched your search

+5 -5
View File
@@ -1,11 +1,11 @@
-- Migration: Add due_date to todos table
-- Migration: Add due_date to note_todos table
-- Description: Adds a due_date column to track task deadlines
-- Add due_date column to todos table
ALTER TABLE todos ADD COLUMN IF NOT EXISTS due_date TIMESTAMPTZ;
-- Add due_date column to note_todos table
ALTER TABLE note_todos ADD COLUMN IF NOT EXISTS due_date TIMESTAMPTZ;
-- Create index on due_date for faster queries
CREATE INDEX IF NOT EXISTS idx_todos_due_date ON todos(due_date);
CREATE INDEX IF NOT EXISTS idx_note_todos_due_date ON note_todos(due_date);
-- Create index on combination of completed and due_date for efficient queries of pending tasks
CREATE INDEX IF NOT EXISTS idx_todos_completed_due_date ON todos(completed, due_date);
CREATE INDEX IF NOT EXISTS idx_note_todos_completed_due_date ON note_todos(completed, due_date);