Kairo-Jinkendo/backend/migrations/006_initiatives_actions.sql
Lars afa68150c0
Some checks failed
Deploy Development / deploy (push) Successful in 33s
Test Suite / pytest-backend (push) Failing after 28s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 7s
Test Suite / compose-smoke (push) Has been skipped
AP0.5: Minimaler Vorhaben- und Maßnahmen-Slice mit Migration 006, CRUD, Assignments und Tests.
2026-07-05 06:15:40 +02:00

50 lines
2.2 KiB
SQL

-- AP0.5: Minimal initiatives (Vorhaben), actions (Maßnahmen), action_assignments
CREATE TABLE initiatives (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
title VARCHAR(255) NOT NULL,
goal TEXT NOT NULL DEFAULT '',
status VARCHAR(32) NOT NULL DEFAULT 'active'
CHECK (status IN ('active', 'paused', 'completed', 'archived')),
priority VARCHAR(16) NOT NULL DEFAULT 'normal'
CHECK (priority IN ('low', 'normal', 'high')),
owner_actor_id UUID NOT NULL REFERENCES actors(id) ON DELETE RESTRICT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_initiatives_tenant ON initiatives(tenant_id);
CREATE INDEX idx_initiatives_owner ON initiatives(owner_actor_id);
CREATE TABLE actions (
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 'open'
CHECK (status IN ('open', 'in_progress', 'blocked', 'done', 'discarded')),
priority VARCHAR(16) NOT NULL DEFAULT 'normal'
CHECK (priority IN ('low', 'normal', 'high')),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_actions_tenant ON actions(tenant_id);
CREATE INDEX idx_actions_initiative ON actions(initiative_id);
CREATE INDEX idx_actions_status ON actions(tenant_id, status);
CREATE TABLE action_assignments (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
action_id UUID NOT NULL REFERENCES actions(id) ON DELETE CASCADE,
actor_id UUID NOT NULL REFERENCES actors(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE (action_id, actor_id)
);
CREATE INDEX idx_action_assignments_tenant ON action_assignments(tenant_id);
CREATE INDEX idx_action_assignments_actor ON action_assignments(actor_id);
CREATE INDEX idx_action_assignments_action ON action_assignments(action_id);