CREATE TABLE IF NOT EXISTS IntelligentAgentObjects (
    AgentId BIGINT NOT NULL,
    OrgUnitId INT NOT NULL,
    AgentName VARCHAR(128),
    Description VARCHAR(1000),
    Enabled TINYINT(1),
    SpecificRoles VARCHAR(1000) COMMENT 'Array of roles or null for all',
    LoginConditionEnabled TINYINT(1),
    LoginConditionThreshold INT,
    LoginConditionType VARCHAR(14),
    AccessConditionEnabled TINYINT(1),
    AccessConditionThreshold INT,
    AccessConditionType VARCHAR(20),
    ResultId BIGINT,
    RepeatType VARCHAR(10),
    EmailWhenSatisfied TINYINT(1),
    EnableSchedule TINYINT(1),
    ScheduleType VARCHAR(8),
    ScheduleRepeatsEvery INT,
    StartDate DATETIME,
    EndDate DATETIME,
    LastModified DATETIME,
    LastModifiedBy INT,
    IsDeleted TINYINT(1),
    PRIMARY KEY (AgentId)
) CHARACTER SET utf8mb4;