CREATE TABLE "grab_files" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"grab_id" uuid NOT NULL,
	"storage_file_id" uuid,
	"imported_path" text NOT NULL,
	"season_number" integer,
	"episode_number" integer,
	"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "grabs" ADD COLUMN "seed_path" text;--> statement-breakpoint
ALTER TABLE "grabs" ADD COLUMN "seed_released_at" timestamp;--> statement-breakpoint
ALTER TABLE "grabs" ADD COLUMN "seed_release_reason" text;--> statement-breakpoint
ALTER TABLE "grab_files" ADD CONSTRAINT "grab_files_grab_id_grabs_id_fk" FOREIGN KEY ("grab_id") REFERENCES "public"."grabs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "grab_files" ADD CONSTRAINT "grab_files_storage_file_id_storage_files_id_fk" FOREIGN KEY ("storage_file_id") REFERENCES "public"."storage_files"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "grab_files_grab_path_idx" ON "grab_files" USING btree ("grab_id","imported_path");--> statement-breakpoint
CREATE INDEX "grab_files_storage_file_idx" ON "grab_files" USING btree ("storage_file_id");