mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-31 06:04:11 +01:00
chore(db): make routine supersession migration idempotent
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
54991df0a7
commit
6e688bde82
1 file changed
+15
-7
@@ -1,7 +1,15 @@
|
||||
ALTER TABLE "issues" ADD COLUMN "superseded_by_issue_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "routine_runs" ADD COLUMN "superseded_by_run_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "routines" ADD COLUMN "lifecycle_policy" text DEFAULT 'independent' NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "issues" ADD CONSTRAINT "issues_superseded_by_issue_id_issues_id_fk" FOREIGN KEY ("superseded_by_issue_id") REFERENCES "public"."issues"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "routine_runs" ADD CONSTRAINT "routine_runs_superseded_by_run_id_routine_runs_id_fk" FOREIGN KEY ("superseded_by_run_id") REFERENCES "public"."routine_runs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "issues_superseded_by_issue_idx" ON "issues" USING btree ("superseded_by_issue_id");--> statement-breakpoint
|
||||
CREATE INDEX "routine_runs_superseded_by_run_idx" ON "routine_runs" USING btree ("superseded_by_run_id");
|
||||
ALTER TABLE "issues" ADD COLUMN IF NOT EXISTS "superseded_by_issue_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "routine_runs" ADD COLUMN IF NOT EXISTS "superseded_by_run_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "routines" ADD COLUMN IF NOT EXISTS "lifecycle_policy" text DEFAULT 'independent' NOT NULL;--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'issues_superseded_by_issue_id_issues_id_fk') THEN
|
||||
ALTER TABLE "issues" ADD CONSTRAINT "issues_superseded_by_issue_id_issues_id_fk" FOREIGN KEY ("superseded_by_issue_id") REFERENCES "public"."issues"("id") ON DELETE set null ON UPDATE no action;
|
||||
END IF;
|
||||
END $$;--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routine_runs_superseded_by_run_id_routine_runs_id_fk') THEN
|
||||
ALTER TABLE "routine_runs" ADD CONSTRAINT "routine_runs_superseded_by_run_id_routine_runs_id_fk" FOREIGN KEY ("superseded_by_run_id") REFERENCES "public"."routine_runs"("id") ON DELETE set null ON UPDATE no action;
|
||||
END IF;
|
||||
END $$;--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "issues_superseded_by_issue_idx" ON "issues" USING btree ("superseded_by_issue_id");--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "routine_runs_superseded_by_run_idx" ON "routine_runs" USING btree ("superseded_by_run_id");
|
||||
Reference in new issue
Block a user