tasq/supabase/migrations/20260221103000_add_clients_and_task_people.sql

28 lines
965 B
PL/PgSQL

-- 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;