CREATE TYPE "public"."maintenance_job_status" AS ENUM('running', 'succeeded', 'failed', 'skipped');--> statement-breakpoint
CREATE TYPE "public"."maintenance_trigger" AS ENUM('scheduled', 'manual');--> statement-breakpoint
CREATE TABLE "maintenance_jobs" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"job" text NOT NULL,
	"trigger" "maintenance_trigger" DEFAULT 'scheduled' NOT NULL,
	"status" "maintenance_job_status" DEFAULT 'running' NOT NULL,
	"started_at" timestamp DEFAULT now() NOT NULL,
	"completed_at" timestamp,
	"duration_ms" integer,
	"exit_code" integer,
	"detail" text,
	"output" text,
	"summary" jsonb
);
--> statement-breakpoint
CREATE INDEX "maintenance_jobs_job_started_idx" ON "maintenance_jobs" USING btree ("job","started_at");