fix: serialize profile reset operations
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
-- A profile database can have only one destructive/runtime operation in flight.
|
||||
-- Existing duplicates intentionally make this migration fail so an operator can
|
||||
-- inspect and resolve them instead of silently discarding an operation.
|
||||
CREATE UNIQUE INDEX "gateway_operation_one_active_per_profile_idx"
|
||||
ON "gateway_operation" ("profile_name")
|
||||
WHERE "status" IN ('QUEUED', 'RUNNING');
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
ALTER TABLE "gateway_operation"
|
||||
ADD COLUMN "lease_owner" TEXT,
|
||||
ADD COLUMN "lease_until" TIMESTAMPTZ,
|
||||
ADD COLUMN "heartbeat_at" TIMESTAMPTZ,
|
||||
ADD COLUMN "attempts" INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
CREATE INDEX "gateway_operation_status_lease_until_created_at_idx"
|
||||
ON "gateway_operation" ("status", "lease_until", "created_at");
|
||||
Reference in New Issue
Block a user