create table if not exists operations_task_progress (
  id uuid primary key default gen_random_uuid(),
  task_type text not null check (task_type in ('preparation', 'delivery', 'pickup', 'verification')),
  task_date date not null,
  task_time varchar(5) not null default '',
  scope_key text not null,
  checked_kinds jsonb not null default '[]'::jsonb,
  finished_at timestamptz,
  finished_by uuid references users(id) on delete set null,
  created_at timestamptz not null default now(),
  updated_at timestamptz not null default now()
);

create unique index if not exists operations_task_progress_unique_idx
  on operations_task_progress (task_type, task_date, task_time, scope_key);

create index if not exists operations_task_progress_task_date_idx
  on operations_task_progress (task_date, task_type);
