-- Migration: add retry tracking columns to outbox table
-- Enables at-least-once delivery with bounded retry (max 3 attempts, 5-minute back-off).

ALTER TABLE "outbox" ADD COLUMN "failed_at" timestamp with time zone;--> statement-breakpoint
ALTER TABLE "outbox" ADD COLUMN "retry_count" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
ALTER TABLE "outbox" ADD COLUMN "last_error" text;--> statement-breakpoint
CREATE INDEX "outbox_retry_idx" ON "outbox" USING btree ("processed_at", "failed_at", "retry_count");
