chore: perauset customer project

This commit is contained in:
e2e
2026-07-11 08:34:30 +02:00
commit 0639909ec6
293 changed files with 28412 additions and 0 deletions

56
sql/0007-tasks.sql Normal file
View File

@@ -0,0 +1,56 @@
-- Task templates
CREATE TABLE app.task_template (
template_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
title TEXT NOT NULL,
description TEXT,
category app.task_category NOT NULL DEFAULT 'operations',
is_claimable BOOLEAN NOT NULL DEFAULT false,
default_location TEXT,
estimated_minutes INT,
recurrence_cron TEXT, -- cron expression, e.g. '0 8 * * 1,3,5'
is_active BOOLEAN NOT NULL DEFAULT true,
created_by_user_id UUID NOT NULL REFERENCES app."user"(user_id),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
-- Task instances
CREATE TABLE app.task_instance (
task_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
template_id UUID REFERENCES app.task_template(template_id),
title TEXT NOT NULL,
description TEXT,
category app.task_category NOT NULL DEFAULT 'operations',
location TEXT,
linked_retreat_id UUID,
linked_stay_id UUID REFERENCES app.stay(stay_id),
scheduled_start_at TIMESTAMPTZ,
scheduled_end_at TIMESTAMPTZ,
status app.task_status NOT NULL DEFAULT 'planned',
created_by_user_id UUID NOT NULL REFERENCES app."user"(user_id),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX idx_task_instance_status ON app.task_instance(status);
CREATE INDEX idx_task_instance_category ON app.task_instance(category);
CREATE INDEX idx_task_instance_template ON app.task_instance(template_id);
-- Task assignments
CREATE TABLE app.task_assignment (
assignment_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
task_instance_id UUID NOT NULL REFERENCES app.task_instance(task_id),
assigned_user_id UUID NOT NULL REFERENCES app."user"(user_id),
assigned_by_user_id UUID NOT NULL REFERENCES app."user"(user_id),
status app.task_assignment_status NOT NULL DEFAULT 'proposed',
notes TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX idx_task_assignment_task ON app.task_assignment(task_instance_id);
CREATE INDEX idx_task_assignment_user ON app.task_assignment(assigned_user_id);
SELECT app.enable_audit('task_template', 'template_id');
SELECT app.enable_audit('task_instance', 'task_id');
SELECT app.enable_audit('task_assignment', 'assignment_id');