From 3fbfdd1f9441299eb146bf215449f238977deb66 Mon Sep 17 00:00:00 2001
From: Peter Stone <thepeterstone@gmail.com>
Date: Mon, 29 Jun 2026 08:53:48 +0000
Subject: feat: native task management + Todoist migration
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Adds doot-owned task storage (native_tasks table) so tasks can be
managed without Todoist. CompleteTask for 'doot' source just updates
the DB — no external API call, no token dependency.

Migration path:
  POST /settings/import-from-todoist  — copies Todoist cache → native_tasks
  Then remove TODOIST_TOKEN from .env to disable Todoist

Changes:
- migration 020: native_tasks table
- store: GetNativeTasks, GetNativeTasksByDateRange, GetUndatedNativeTasks,
  CreateNativeTask, CompleteNativeTask, UncompleteNativeTask,
  UpdateNativeTask, ImportFromTodoist
- timeline: native tasks appear as source="doot" (teal)
- handleAtomToggle: "doot" case — no external API needed
- HandleWidgetComplete: method on Handler, handles "doot" natively
- HandleUnifiedAdd: "doot" source creates in native_tasks
- widget: "doot" tasks are completable, teal color indicator

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---
 migrations/020_native_tasks.sql | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 migrations/020_native_tasks.sql

(limited to 'migrations/020_native_tasks.sql')

diff --git a/migrations/020_native_tasks.sql b/migrations/020_native_tasks.sql
new file mode 100644
index 0000000..9abf3ad
--- /dev/null
+++ b/migrations/020_native_tasks.sql
@@ -0,0 +1,17 @@
+-- Native tasks table: doot-owned task storage, not a sync cache.
+-- Populated by importing from Todoist, then managed entirely within doot.
+CREATE TABLE IF NOT EXISTS native_tasks (
+    id TEXT PRIMARY KEY,
+    content TEXT NOT NULL,
+    description TEXT DEFAULT '',
+    project_name TEXT DEFAULT '',
+    due_date DATETIME,
+    priority INTEGER DEFAULT 1,
+    completed BOOLEAN DEFAULT 0,
+    labels TEXT DEFAULT '[]',
+    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX IF NOT EXISTS idx_native_tasks_due_date ON native_tasks(due_date);
+CREATE INDEX IF NOT EXISTS idx_native_tasks_completed ON native_tasks(completed);
-- 
cgit v1.2.3

