CREATE TABLE `tasks` (
	`id` int AUTO_INCREMENT NOT NULL,
	`agentId` int NOT NULL,
	`conversationId` varchar(64),
	`title` varchar(255) NOT NULL,
	`description` text,
	`status` enum('pending','in_progress','completed','failed','blocked') NOT NULL DEFAULT 'pending',
	`priority` enum('low','medium','high','critical') NOT NULL DEFAULT 'medium',
	`dependsOn` json DEFAULT ('[]'),
	`result` text,
	`errorMessage` text,
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	`startedAt` timestamp,
	`completedAt` timestamp,
	`metadata` json DEFAULT ('{}'),
	CONSTRAINT `tasks_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE INDEX `tasks_agentId_idx` ON `tasks` (`agentId`);--> statement-breakpoint
CREATE INDEX `tasks_status_idx` ON `tasks` (`status`);--> statement-breakpoint
CREATE INDEX `tasks_conversationId_idx` ON `tasks` (`conversationId`);