From b3253f4c0e97cedc08516fd31a58170842ee35af Mon Sep 17 00:00:00 2001 From: Dotta Date: Sun, 19 Apr 2026 20:42:08 -0500 Subject: [PATCH] Make liveness migration idempotent Co-Authored-By: Paperclip --- packages/db/src/migrations/0058_wealthy_starbolt.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/db/src/migrations/0058_wealthy_starbolt.sql b/packages/db/src/migrations/0058_wealthy_starbolt.sql index 139eb3dcab0..360dcf81a3b 100644 --- a/packages/db/src/migrations/0058_wealthy_starbolt.sql +++ b/packages/db/src/migrations/0058_wealthy_starbolt.sql @@ -1,6 +1,6 @@ -ALTER TABLE "heartbeat_runs" ADD COLUMN "liveness_state" text;--> statement-breakpoint -ALTER TABLE "heartbeat_runs" ADD COLUMN "liveness_reason" text;--> statement-breakpoint -ALTER TABLE "heartbeat_runs" ADD COLUMN "continuation_attempt" integer DEFAULT 0 NOT NULL;--> statement-breakpoint -ALTER TABLE "heartbeat_runs" ADD COLUMN "last_useful_action_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "heartbeat_runs" ADD COLUMN "next_action" text;--> statement-breakpoint -CREATE INDEX "heartbeat_runs_company_liveness_idx" ON "heartbeat_runs" USING btree ("company_id","liveness_state","created_at"); \ No newline at end of file +ALTER TABLE "heartbeat_runs" ADD COLUMN IF NOT EXISTS "liveness_state" text;--> statement-breakpoint +ALTER TABLE "heartbeat_runs" ADD COLUMN IF NOT EXISTS "liveness_reason" text;--> statement-breakpoint +ALTER TABLE "heartbeat_runs" ADD COLUMN IF NOT EXISTS "continuation_attempt" integer DEFAULT 0 NOT NULL;--> statement-breakpoint +ALTER TABLE "heartbeat_runs" ADD COLUMN IF NOT EXISTS "last_useful_action_at" timestamp with time zone;--> statement-breakpoint +ALTER TABLE "heartbeat_runs" ADD COLUMN IF NOT EXISTS "next_action" text;--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "heartbeat_runs_company_liveness_idx" ON "heartbeat_runs" USING btree ("company_id","liveness_state","created_at");