-- Migration: 0006_agent_container_fields
-- Add Docker Swarm container tracking fields to agents table.
-- Each agent can now be deployed as an autonomous Swarm service.

ALTER TABLE `agents`
  ADD COLUMN `serviceName`     VARCHAR(100)  NULL         COMMENT 'Docker Swarm service name: goclaw-agent-{id}',
  ADD COLUMN `servicePort`     INT           NULL         COMMENT 'HTTP API port inside overlay network (8001-8999)',
  ADD COLUMN `containerImage`  VARCHAR(255)  NOT NULL DEFAULT 'goclaw-agent-worker:latest' COMMENT 'Docker image to run',
  ADD COLUMN `containerStatus` ENUM('stopped','deploying','running','error') NOT NULL DEFAULT 'stopped' COMMENT 'Current container lifecycle state';

-- Index for quick lookup of running agents
CREATE INDEX `agents_containerStatus_idx` ON `agents` (`containerStatus`);
