From e6cd65300f5ac5b99a40e73a41c6ebda90496cfd Mon Sep 17 00:00:00 2001 From: abelanger5 Date: Wed, 27 Nov 2024 14:50:00 -0500 Subject: [PATCH] fix: make cron migration more performant (#1076) * fix: make cron migration more performant * whitespace --- README.md | 2 +- sql/migrations/20241121142159_v0.52.0.sql | 14 +++++++++++++- sql/migrations/atlas.sum | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3d8722c32..7887f639c 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Hatchet replaces difficult to manage legacy queues or pub/sub systems so you can **Example Use Cases:** -- **AI Agents:** define your agentic workflows as code and leverage Hatchet to retry failures and parallelize agent actions. +- **AI Agents:** define your agentic workflows as code and leverage Hatchet to retry failures and parallelize agent actions. - **Fairness for Generative AI:** Don't let busy users overwhelm your system. Hatchet lets you distribute requests to your workers fairly with configurable policies. - **Batch Processing for Document Indexing:** Hatchet can handle large-scale batch processing of documents, images, and other data and resume mid-job on failure. - **Workflow Orchestration for Multi-Modal Systems:** Hatchet can handle orchestrating multi-modal inputs and outputs, with full DAG-style execution. diff --git a/sql/migrations/20241121142159_v0.52.0.sql b/sql/migrations/20241121142159_v0.52.0.sql index d94b9be8e..9476d02df 100644 --- a/sql/migrations/20241121142159_v0.52.0.sql +++ b/sql/migrations/20241121142159_v0.52.0.sql @@ -12,7 +12,19 @@ CREATE TYPE "WorkflowTriggerScheduledRefMethods" AS ENUM ('DEFAULT', 'API'); ALTER TABLE "WorkflowTriggerCronRef" ADD COLUMN "name" text NULL, ADD COLUMN "id" uuid NOT NULL, ADD COLUMN "method" "WorkflowTriggerCronRefMethods" NOT NULL DEFAULT 'DEFAULT', ADD CONSTRAINT "WorkflowTriggerCronRef_parentId_cron_name_key" UNIQUE ("parentId", "cron", "name"); -- Modify "WorkflowTriggerScheduledRef" table ALTER TABLE "WorkflowTriggerScheduledRef" ADD COLUMN "method" "WorkflowTriggerScheduledRefMethods" NOT NULL DEFAULT 'DEFAULT'; + -- Modify "WorkflowRunTriggeredBy" table -ALTER TABLE "WorkflowRunTriggeredBy" DROP CONSTRAINT "WorkflowRunTriggeredBy_cronParentId_cronSchedule_fkey", ADD COLUMN "cronName" text NULL, ADD CONSTRAINT "WorkflowRunTriggeredBy_cronParentId_cronSchedule_cronName_fkey" FOREIGN KEY ("cronParentId", "cronSchedule", "cronName") REFERENCES "WorkflowTriggerCronRef" ("parentId", "cron", "name") ON UPDATE CASCADE ON DELETE SET NULL; +ALTER TABLE "WorkflowRunTriggeredBy" +DROP CONSTRAINT "WorkflowRunTriggeredBy_cronParentId_cronSchedule_fkey", +ADD COLUMN "cronName" text NULL; + +ALTER TABLE "WorkflowRunTriggeredBy" +ADD CONSTRAINT "WorkflowRunTriggeredBy_cronParentId_cronSchedule_cronName_fkey" +FOREIGN KEY ("cronParentId", "cronSchedule", "cronName") +REFERENCES "WorkflowTriggerCronRef" ("parentId", "cron", "name") +ON UPDATE CASCADE +ON DELETE SET NULL +NOT VALID; + -- Drop index "WorkflowTriggerCronRef_parentId_cron_key" from table: "WorkflowTriggerCronRef" DROP INDEX "WorkflowTriggerCronRef_parentId_cron_key"; \ No newline at end of file diff --git a/sql/migrations/atlas.sum b/sql/migrations/atlas.sum index 194f9d1e9..3aaf2867b 100644 --- a/sql/migrations/atlas.sum +++ b/sql/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:ttKQZ/+X6AnYVp7nozbGyoby/BNrbML2MxWaMwrgNmA= +h1:k8i1YyttxFMF1D3qndWWDz53IGb+MG6BGDN4MUZXqUY= 20240115180414_init.sql h1:Ef3ZyjAHkmJPdGF/dEWCahbwgcg6uGJKnDxW2JCRi2k= 20240122014727_v0_6_0.sql h1:o/LdlteAeFgoHJ3e/M4Xnghqt9826IE/Y/h0q95Acuo= 20240126235456_v0_7_0.sql h1:KiVzt/hXgQ6esbdC6OMJOOWuYEXmy1yeCpmsVAHTFKs= @@ -75,4 +75,4 @@ h1:ttKQZ/+X6AnYVp7nozbGyoby/BNrbML2MxWaMwrgNmA= 20241029122625_v0.51.0.sql h1:nOa4FqmZxSh1yBOJyduX+j15gQavjizTn660wyXjhNk= 20241107162939_v0.51.2.sql h1:qtnUITelb0kzAazo99gdTzejmQeOiE8NTP8b8bpQuF0= 20241114175346_v0.51.3.sql h1:ZbpRJsCmt6098ilZ3LtOk9LXRzuuwiznXPJmSkZSRpg= -20241121142159_v0.52.0.sql h1:nVceeHB+PW9R0FBTCalGamY1l9n5mOrmCpuiH1QkVB4= +20241121142159_v0.52.0.sql h1:Aw4tw+g2CUe7W/JVD+fDX4tXeP5FLNIU3f8U1jtRMnc=