From e4b17c1f8c7d380f4fe5287aac6052e76d15dd3e Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 23:42:18 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/integrations/supabase/types.ts | 30 +++++++++++++++++++ ...2_ca04f69b-9fb3-4d85-bd8f-dca0a67f08c7.sql | 14 +++++++++ 2 files changed, 44 insertions(+) create mode 100644 supabase/migrations/20260418234212_ca04f69b-9fb3-4d85-bd8f-dca0a67f08c7.sql diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index 6487e8a..8107b43 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -657,8 +657,10 @@ export type Database = { id: string sort_order: number stage_key: string | null + template_task_id: string | null title: string updated_at: string + workflow_template_id: string | null } Insert: { assignee_id?: string | null @@ -671,8 +673,10 @@ export type Database = { id?: string sort_order?: number stage_key?: string | null + template_task_id?: string | null title: string updated_at?: string + workflow_template_id?: string | null } Update: { assignee_id?: string | null @@ -685,8 +689,10 @@ export type Database = { id?: string sort_order?: number stage_key?: string | null + template_task_id?: string | null title?: string updated_at?: string + workflow_template_id?: string | null } Relationships: [ { @@ -710,6 +716,20 @@ export type Database = { referencedRelation: "collection_workflow_stages" referencedColumns: ["key"] }, + { + foreignKeyName: "collection_tasks_template_task_id_fkey" + columns: ["template_task_id"] + isOneToOne: false + referencedRelation: "workflow_template_tasks" + referencedColumns: ["id"] + }, + { + foreignKeyName: "collection_tasks_workflow_template_id_fkey" + columns: ["workflow_template_id"] + isOneToOne: false + referencedRelation: "workflow_templates" + referencedColumns: ["id"] + }, ] } collection_workflow_stages: { @@ -2701,6 +2721,7 @@ export type Database = { priority: Database["public"]["Enums"]["task_priority"] sort_order: number status: Database["public"]["Enums"]["task_status"] + template_task_id: string | null title: string updated_at: string workflow_template_id: string | null @@ -2719,6 +2740,7 @@ export type Database = { priority?: Database["public"]["Enums"]["task_priority"] sort_order?: number status?: Database["public"]["Enums"]["task_status"] + template_task_id?: string | null title: string updated_at?: string workflow_template_id?: string | null @@ -2737,6 +2759,7 @@ export type Database = { priority?: Database["public"]["Enums"]["task_priority"] sort_order?: number status?: Database["public"]["Enums"]["task_status"] + template_task_id?: string | null title?: string updated_at?: string workflow_template_id?: string | null @@ -2756,6 +2779,13 @@ export type Database = { referencedRelation: "tasks" referencedColumns: ["id"] }, + { + foreignKeyName: "tasks_template_task_id_fkey" + columns: ["template_task_id"] + isOneToOne: false + referencedRelation: "workflow_template_tasks" + referencedColumns: ["id"] + }, { foreignKeyName: "tasks_workflow_template_id_fkey" columns: ["workflow_template_id"] diff --git a/supabase/migrations/20260418234212_ca04f69b-9fb3-4d85-bd8f-dca0a67f08c7.sql b/supabase/migrations/20260418234212_ca04f69b-9fb3-4d85-bd8f-dca0a67f08c7.sql new file mode 100644 index 0000000..02cbbad --- /dev/null +++ b/supabase/migrations/20260418234212_ca04f69b-9fb3-4d85-bd8f-dca0a67f08c7.sql @@ -0,0 +1,14 @@ + +-- Add template_task_id to tasks for sequential chaining +ALTER TABLE public.tasks + ADD COLUMN IF NOT EXISTS template_task_id uuid REFERENCES public.workflow_template_tasks(id) ON DELETE SET NULL; + +CREATE INDEX IF NOT EXISTS idx_tasks_template_task ON public.tasks(template_task_id); + +-- Allow workflow_templates on collections too +ALTER TABLE public.collection_tasks + ADD COLUMN IF NOT EXISTS workflow_template_id uuid REFERENCES public.workflow_templates(id) ON DELETE SET NULL, + ADD COLUMN IF NOT EXISTS template_task_id uuid REFERENCES public.workflow_template_tasks(id) ON DELETE SET NULL; + +CREATE INDEX IF NOT EXISTS idx_collection_tasks_workflow_template ON public.collection_tasks(workflow_template_id); +CREATE INDEX IF NOT EXISTS idx_collection_tasks_template_task ON public.collection_tasks(template_task_id);