-- Phase 18: per-cell task-assignment status + global feature toggle.
--
-- task_assignments.status names where this cell sits in the workflow:
--   zugewiesen    — assigned (default; transparent in UI)
--   gestartet     — in progress (yellow)
--   abgeschlossen — done (green)
--   abgebrochen   — cancelled (red)
--
-- The whole feature is gated by app_settings.task_status_enabled. Default is
-- '0' (disabled) so the UI is unchanged on first deploy until an admin flips
-- it on under /settings.

ALTER TABLE task_assignments
    ADD COLUMN status TEXT NOT NULL DEFAULT 'zugewiesen'
    CHECK (status IN ('zugewiesen','gestartet','abgeschlossen','abgebrochen'));

CREATE TABLE app_settings (
    key        TEXT PRIMARY KEY,
    value      TEXT NOT NULL,
    updated_at TEXT NOT NULL
);

INSERT INTO app_settings (key, value, updated_at)
VALUES ('task_status_enabled', '0', strftime('%Y-%m-%dT%H:%M:%SZ', 'now'));
