-- Inter-agent conversations
CREATE TABLE `conversations` (
	`id` text PRIMARY KEY NOT NULL,
	`from_agent_id` text NOT NULL REFERENCES `agents`(`id`) ON DELETE CASCADE,
	`to_agent_id` text NOT NULL REFERENCES `agents`(`id`) ON DELETE CASCADE,
	`initiative_id` text REFERENCES `initiatives`(`id`) ON DELETE SET NULL,
	`phase_id` text REFERENCES `phases`(`id`) ON DELETE SET NULL,
	`task_id` text REFERENCES `tasks`(`id`) ON DELETE SET NULL,
	`question` text NOT NULL,
	`answer` text,
	`status` text DEFAULT 'pending' NOT NULL,
	`created_at` integer NOT NULL,
	`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE INDEX `conversations_to_agent_status_idx` ON `conversations` (`to_agent_id`, `status`);
--> statement-breakpoint
CREATE INDEX `conversations_from_agent_idx` ON `conversations` (`from_agent_id`);
