Added Type, Category and Signatories on task

This commit is contained in:
2026-02-21 14:33:22 +08:00
parent d32449d096
commit 8d31a629ac
14 changed files with 1178 additions and 48 deletions
@@ -0,0 +1,6 @@
-- Add request type/category metadata to tasks table
alter table tasks
add column request_type text,
add column request_type_other text,
add column request_category text;
@@ -0,0 +1,25 @@
-- Convert request_type and request_category columns to enums
-- create enum types
create type request_type as enum (
'Install',
'Repair',
'Upgrade',
'Replace',
'Other'
);
create type request_category as enum (
'Software',
'Hardware',
'Network'
);
-- alter existing columns to use the enum types
alter table tasks
alter column request_type type request_type using (
case when request_type is null then null else request_type::request_type end
),
alter column request_category type request_category using (
case when request_category is null then null else request_category::request_category end
);
@@ -0,0 +1,27 @@
-- Migration: add clients table and task person fields (requested/noted/received)
-- Created: 2026-02-21 10:30:00
BEGIN;
-- Clients table to store non-profile requesters/receivers
CREATE TABLE IF NOT EXISTS clients (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
name text NOT NULL,
contact jsonb DEFAULT '{}'::jsonb,
created_at timestamptz NOT NULL DEFAULT now()
);
-- Ensure we can efficiently search clients by name
CREATE INDEX IF NOT EXISTS clients_name_idx ON clients (lower(name));
-- Add nullable person fields to tasks (requested_by, noted_by, received_by)
ALTER TABLE IF EXISTS tasks
ADD COLUMN IF NOT EXISTS requested_by text,
ADD COLUMN IF NOT EXISTS noted_by text,
ADD COLUMN IF NOT EXISTS received_by text;
CREATE INDEX IF NOT EXISTS tasks_requested_by_idx ON tasks (requested_by);
CREATE INDEX IF NOT EXISTS tasks_noted_by_idx ON tasks (noted_by);
CREATE INDEX IF NOT EXISTS tasks_received_by_idx ON tasks (received_by);
COMMIT;