-- V003: ai_agent_groups
-- AI 에이전트 그룹 테이블

CREATE TABLE ai_agent_groups (
    id              BIGSERIAL PRIMARY KEY,
    group_id        VARCHAR(64) NOT NULL UNIQUE,
    name            VARCHAR(200) NOT NULL,
    description     TEXT,
    execution_mode  VARCHAR(20) NOT NULL DEFAULT 'mixed'
                    CHECK (execution_mode IN ('parallel','sequential','mixed')),
    status          VARCHAR(20) NOT NULL DEFAULT 'active'
                    CHECK (status IN ('active','inactive','archived')),
    company_code    VARCHAR(20),
    created_by      VARCHAR(64) NOT NULL,
    created_at      TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at      TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_ai_groups_company ON ai_agent_groups (company_code);
CREATE INDEX idx_ai_groups_status  ON ai_agent_groups (status);
