Add plan dates, postponing, backlog and projects
- Tasks get an optional plan date separate from the deadline. Unfinished plans roll over in Today; only missed deadlines count as overdue. - Postpone sheet on every task (tomorrow, weekend, next week, ...) that can move either the plan date or the deadline, with undo. - Backlog view for undated tasks, with suggestions in Today. - Projects with deadline, notes, progress, next step and "falling behind" warnings, shown in Today and in their own view. - Times and the calendar now follow the plan date (else the deadline). - Schema v3 migration (backup taken first); export format v3 includes projects and still imports older files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import sqlite3
|
||||
from pathlib import Path
|
||||
|
||||
DB_PATH = os.environ.get("DB_PATH", "/data/whattodo.db")
|
||||
SCHEMA_VERSION = 2
|
||||
SCHEMA_VERSION = 3
|
||||
|
||||
DEFAULT_CATEGORIES = [
|
||||
("Work", "#2563eb"),
|
||||
@@ -23,13 +23,26 @@ CREATE TABLE IF NOT EXISTS categories (
|
||||
color TEXT NOT NULL DEFAULT '#6b7280',
|
||||
position INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS projects (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
notes TEXT NOT NULL DEFAULT '',
|
||||
category_id INTEGER REFERENCES categories(id) ON DELETE SET NULL,
|
||||
due_date TEXT,
|
||||
done INTEGER NOT NULL DEFAULT 0,
|
||||
done_at TEXT,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS tasks (
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT NOT NULL,
|
||||
notes TEXT NOT NULL DEFAULT '',
|
||||
category_id INTEGER REFERENCES categories(id) ON DELETE SET NULL,
|
||||
project_id INTEGER REFERENCES projects(id) ON DELETE SET NULL,
|
||||
priority INTEGER NOT NULL DEFAULT 0,
|
||||
due_date TEXT,
|
||||
planned_date TEXT,
|
||||
start_time TEXT,
|
||||
end_time TEXT,
|
||||
tags TEXT NOT NULL DEFAULT '[]',
|
||||
@@ -96,6 +109,12 @@ def migrate(conn: sqlite3.Connection, version: int) -> None:
|
||||
if version < 2:
|
||||
conn.execute("ALTER TABLE tasks ADD COLUMN start_time TEXT")
|
||||
conn.execute("ALTER TABLE tasks ADD COLUMN end_time TEXT")
|
||||
if version < 3:
|
||||
# The projects table itself is created by SCHEMA before migrating.
|
||||
conn.execute("ALTER TABLE tasks ADD COLUMN planned_date TEXT")
|
||||
conn.execute(
|
||||
"ALTER TABLE tasks ADD COLUMN project_id INTEGER REFERENCES projects(id) ON DELETE SET NULL"
|
||||
)
|
||||
conn.execute(
|
||||
"UPDATE meta SET value = ? WHERE key = 'schema_version'", (str(SCHEMA_VERSION),)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user