From 1d5442826e7d889cff17ff73e11fdd00e37f953c Mon Sep 17 00:00:00 2001 From: Nicky Leach Date: Tue, 6 Oct 2026 11:14:20 -0700 Subject: [PATCH] Allow archive migration on older logical restores Older JavaScript backups omit check constraints. Tolerate a missing lifecycle action constraint when replacing it, then install the full archive-capable constraint. All 20 lifecycle, snapshot, and lagging restore checks pass. Co-Authored-By: Paperclip --- packages/db/src/migrations/0306_many_sabretooth.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/db/src/migrations/0306_many_sabretooth.sql b/packages/db/src/migrations/0306_many_sabretooth.sql index a5005e35cf1..a9bd927e2c0 100644 --- a/packages/db/src/migrations/0306_many_sabretooth.sql +++ b/packages/db/src/migrations/0306_many_sabretooth.sql @@ -1,2 +1,3 @@ -ALTER TABLE "resource_lifecycle_events" DROP CONSTRAINT "resource_lifecycle_events_action_check";--> statement-breakpoint -ALTER TABLE "resource_lifecycle_events" ADD CONSTRAINT "resource_lifecycle_events_action_check" CHECK ("resource_lifecycle_events"."action" = 'create' OR ("resource_lifecycle_events"."resource_type" = 'project' AND "resource_lifecycle_events"."action" IN ('update', 'archive')) OR ("resource_lifecycle_events"."resource_type" = 'agent' AND "resource_lifecycle_events"."action" IN ('pause', 'resume', 'terminate'))); \ No newline at end of file +-- Older JavaScript restores can omit check constraints. +ALTER TABLE "resource_lifecycle_events" DROP CONSTRAINT IF EXISTS "resource_lifecycle_events_action_check";--> statement-breakpoint +ALTER TABLE "resource_lifecycle_events" ADD CONSTRAINT "resource_lifecycle_events_action_check" CHECK ("resource_lifecycle_events"."action" = 'create' OR ("resource_lifecycle_events"."resource_type" = 'project' AND "resource_lifecycle_events"."action" IN ('update', 'archive')) OR ("resource_lifecycle_events"."resource_type" = 'agent' AND "resource_lifecycle_events"."action" IN ('pause', 'resume', 'terminate')));