Files

17 lines
1.7 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- "Control:" todo: задачу поставили исполнителю, а контролёр (например CEO) получил парное todo "Control: ...".
-- Слежение за парами: исполнитель закрыл todo -> контролёру "(выполнено)" и сообщение; 2 дня без действий после срока -> "(просрочено)".
create table control_todo (
id uuid primary key default gen_random_uuid(),
controller_person_id uuid not null references person(id), -- чей агент пишет контролёру (чат контролёра)
executor_task_id text not null, -- todo исполнителя в JobTread
control_task_id text not null unique, -- парное "Control:" todo контролёра
executor_name text, -- название todo исполнителя (для сообщения, пока нет в зеркале)
control_due date, -- срок Control todo (срок исполнителя + 2 дня)
status text not null default 'active' check (status in ('active', 'overdue', 'done', 'closed')),
created_at timestamptz not null default now(),
notified_at timestamptz, -- когда агент последний раз сообщал контролёру о смене статуса
updated_at timestamptz not null default now()
);
create index control_todo_open_idx on control_todo (status) where status in ('active', 'overdue');
alter table control_todo enable row level security;