All checks were successful
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 1m6s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 21s
Test Suite / playwright-smoke (push) Successful in 14s
Schließt den zweiten OM-Slice entlang der Roadmap: neue Entitäten parallel im Vorhaben, erweiterte Action-Status/Fälligkeit und Attention-Regeln 7–9. Co-authored-by: Cursor <cursoragent@cursor.com>
83 lines
3.7 KiB
SQL
83 lines
3.7 KiB
SQL
-- AP0.9: Operating Model Extension II — evidence, decisions, reviews, recurring_elements, action due_at
|
|
|
|
ALTER TABLE actions ADD COLUMN due_at TIMESTAMPTZ NULL;
|
|
|
|
ALTER TABLE actions DROP CONSTRAINT actions_status_check;
|
|
|
|
ALTER TABLE actions ADD CONSTRAINT actions_status_check
|
|
CHECK (status IN (
|
|
'open', 'ready', 'in_progress', 'blocked', 'review_required', 'done', 'discarded'
|
|
));
|
|
|
|
CREATE INDEX idx_actions_due_at ON actions(tenant_id, due_at) WHERE due_at IS NOT NULL;
|
|
|
|
CREATE TABLE evidence (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
initiative_id UUID NOT NULL REFERENCES initiatives(id) ON DELETE CASCADE,
|
|
action_id UUID NULL REFERENCES actions(id) ON DELETE SET NULL,
|
|
milestone_id UUID NULL REFERENCES milestones(id) ON DELETE SET NULL,
|
|
title VARCHAR(255) NOT NULL,
|
|
description TEXT NOT NULL DEFAULT '',
|
|
status VARCHAR(32) NOT NULL DEFAULT 'submitted'
|
|
CHECK (status IN ('submitted', 'accepted', 'rejected')),
|
|
submitted_by_actor_id UUID NULL REFERENCES actors(id) ON DELETE SET NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_evidence_tenant_initiative ON evidence(tenant_id, initiative_id);
|
|
|
|
CREATE TABLE decisions (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
initiative_id UUID NOT NULL REFERENCES initiatives(id) ON DELETE CASCADE,
|
|
title VARCHAR(255) NOT NULL,
|
|
description TEXT NOT NULL DEFAULT '',
|
|
status VARCHAR(32) NOT NULL DEFAULT 'proposed'
|
|
CHECK (status IN ('proposed', 'decided', 'superseded')),
|
|
outcome TEXT NOT NULL DEFAULT '',
|
|
decided_by_actor_id UUID NULL REFERENCES actors(id) ON DELETE SET NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_decisions_tenant_initiative ON decisions(tenant_id, initiative_id);
|
|
|
|
CREATE TABLE reviews (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
initiative_id UUID NOT NULL REFERENCES initiatives(id) ON DELETE CASCADE,
|
|
action_id UUID NULL REFERENCES actions(id) ON DELETE SET NULL,
|
|
milestone_id UUID NULL REFERENCES milestones(id) ON DELETE SET NULL,
|
|
title VARCHAR(255) NOT NULL,
|
|
summary TEXT NOT NULL DEFAULT '',
|
|
status VARCHAR(32) NOT NULL DEFAULT 'planned'
|
|
CHECK (status IN ('planned', 'completed', 'skipped')),
|
|
due_at TIMESTAMPTZ NULL,
|
|
reviewed_by_actor_id UUID NULL REFERENCES actors(id) ON DELETE SET NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_reviews_tenant_initiative ON reviews(tenant_id, initiative_id);
|
|
CREATE INDEX idx_reviews_due_at ON reviews(tenant_id, due_at) WHERE due_at IS NOT NULL;
|
|
|
|
CREATE TABLE recurring_elements (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
initiative_id UUID NOT NULL REFERENCES initiatives(id) ON DELETE CASCADE,
|
|
title VARCHAR(255) NOT NULL,
|
|
description TEXT NOT NULL DEFAULT '',
|
|
status VARCHAR(32) NOT NULL DEFAULT 'active'
|
|
CHECK (status IN ('active', 'paused', 'ended')),
|
|
interval_days INT NULL CHECK (interval_days IS NULL OR interval_days > 0),
|
|
next_due_at TIMESTAMPTZ NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_recurring_elements_tenant_initiative ON recurring_elements(tenant_id, initiative_id);
|
|
CREATE INDEX idx_recurring_elements_next_due ON recurring_elements(tenant_id, next_due_at)
|
|
WHERE next_due_at IS NOT NULL;
|