CREATE TYPE "public"."corrupt_file_status" AS ENUM('pending', 'approved', 'deleted', 'dismissed', 'failed');--> statement-breakpoint
CREATE TABLE "corrupt_files" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"full_path" text NOT NULL,
	"agent" text NOT NULL,
	"tier" text,
	"reason" text NOT NULL,
	"size_bytes" bigint,
	"status" "corrupt_file_status" DEFAULT 'pending' NOT NULL,
	"first_detected_at" timestamp DEFAULT now() NOT NULL,
	"last_detected_at" timestamp DEFAULT now() NOT NULL,
	"reviewed_by" uuid,
	"reviewed_at" timestamp,
	"deleted_at" timestamp,
	"delete_error" text,
	CONSTRAINT "corrupt_files_full_path_unique" UNIQUE("full_path")
);
--> statement-breakpoint
ALTER TABLE "corrupt_files" ADD CONSTRAINT "corrupt_files_reviewed_by_users_id_fk" FOREIGN KEY ("reviewed_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;