CREATE TABLE `vision_reference_images` (
	`id` int AUTO_INCREMENT NOT NULL,
	`slug` varchar(128) NOT NULL,
	`title` varchar(256) NOT NULL,
	`exerciseType` varchar(64) NOT NULL,
	`imageUrl` text NOT NULL,
	`sourcePageUrl` text NOT NULL,
	`sourceLabel` varchar(128) NOT NULL,
	`author` varchar(128),
	`license` varchar(128),
	`expectedFocus` json,
	`tags` json,
	`notes` text,
	`sortOrder` int NOT NULL DEFAULT 0,
	`isPublished` int NOT NULL DEFAULT 1,
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `vision_reference_images_id` PRIMARY KEY(`id`),
	CONSTRAINT `vision_reference_images_slug_unique` UNIQUE(`slug`)
);
--> statement-breakpoint
CREATE TABLE `vision_test_runs` (
	`id` int AUTO_INCREMENT NOT NULL,
	`taskId` varchar(64) NOT NULL,
	`userId` int NOT NULL,
	`referenceImageId` int,
	`title` varchar(256) NOT NULL,
	`exerciseType` varchar(64) NOT NULL,
	`imageUrl` text NOT NULL,
	`status` enum('queued','succeeded','failed') NOT NULL DEFAULT 'queued',
	`visionStatus` enum('pending','ok','fallback','failed') NOT NULL DEFAULT 'pending',
	`configuredModel` varchar(128),
	`expectedFocus` json,
	`summary` text,
	`corrections` text,
	`report` json,
	`warning` text,
	`error` text,
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `vision_test_runs_id` PRIMARY KEY(`id`),
	CONSTRAINT `vision_test_runs_taskId_unique` UNIQUE(`taskId`)
);
