mirror of
https://github.com/R0m1k3/noteflow.git
synced 2026-10-11 17:29:37 +02:00
- 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
17 lines
896 B
SQL
17 lines
896 B
SQL
-- Migration: Add subtasks support to todos tables
|
|
-- Description: Adds parent_id column to enable hierarchical task structure
|
|
|
|
-- Add parent_id column to note_todos table (note todos)
|
|
ALTER TABLE note_todos ADD COLUMN IF NOT EXISTS parent_id INTEGER REFERENCES note_todos(id) ON DELETE CASCADE;
|
|
|
|
-- Add parent_id column to global_todos table
|
|
ALTER TABLE global_todos ADD COLUMN IF NOT EXISTS parent_id INTEGER REFERENCES global_todos(id) ON DELETE CASCADE;
|
|
|
|
-- Create indexes for faster subtask queries
|
|
CREATE INDEX IF NOT EXISTS idx_note_todos_parent_id ON note_todos(parent_id);
|
|
CREATE INDEX IF NOT EXISTS idx_global_todos_parent_id ON global_todos(parent_id);
|
|
|
|
-- Add level column to track depth (optional, for UI optimization)
|
|
ALTER TABLE note_todos ADD COLUMN IF NOT EXISTS level INTEGER DEFAULT 0;
|
|
ALTER TABLE global_todos ADD COLUMN IF NOT EXISTS level INTEGER DEFAULT 0;
|