CREATE TABLE `download_jobs` (
	`id` int AUTO_INCREMENT NOT NULL,
	`userId` int NOT NULL,
	`sourceUrl` varchar(2048) NOT NULL,
	`sourceType` enum('wayback','live') NOT NULL DEFAULT 'wayback',
	`status` enum('queued','in progress','done','failed') NOT NULL DEFAULT 'queued',
	`progressPercent` int NOT NULL DEFAULT 0,
	`totalAssets` int DEFAULT 0,
	`downloadedAssets` int DEFAULT 0,
	`archiveUrl` varchar(2048),
	`zipFileUrl` varchar(2048),
	`zipFileKey` varchar(512),
	`errorMessage` text,
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	`completedAt` timestamp,
	CONSTRAINT `download_jobs_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `job_assets` (
	`id` int AUTO_INCREMENT NOT NULL,
	`jobId` int NOT NULL,
	`assetUrl` varchar(2048) NOT NULL,
	`assetType` varchar(64) NOT NULL,
	`localPath` varchar(512) NOT NULL,
	`status` enum('pending','downloaded','failed') NOT NULL DEFAULT 'pending',
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	CONSTRAINT `job_assets_id` PRIMARY KEY(`id`)
);
