CREATE TABLE QueueCallLog
(
    id BIGINT UNSIGNED DEFAULT NULL AUTO_INCREMENT,
    CallId VARCHAR(100) DEFAULT NULL,
    Queue BIGINT UNSIGNED DEFAULT NULL,
    Skill BIGINT UNSIGNED DEFAULT NULL,
    Agent BIGINT UNSIGNED DEFAULT NULL,
    Name VARCHAR(20) DEFAULT NULL,
    Number VARCHAR(30) DEFAULT NULL,
    Start BIGINT UNSIGNED DEFAULT NULL,
    End BIGINT UNSIGNED DEFAULT NULL,
    Duration INT UNSIGNED DEFAULT NULL,
    EnterTs BIGINT UNSIGNED DEFAULT 0,
    Direction ENUM("EXTERNAL_OUTBOUND", "INTERNAL_OUTBOUND", "INBOUND") DEFAULT "INBOUND",
    ExitReason VARCHAR(30) DEFAULT NULL,
    PRIMARY KEY ( id ) ,
    /* @todo Improve KEY/INDEX usage by refactoring how this table is used.. */
    KEY ( CallId ),
    KEY ( Queue, EnterTs ),
    KEY ( Queue, Start ),
    KEY ( Queue, End ),
    KEY ( End, Queue ),
    KEY ( Agent, End )
    /* ,                          FOREIGN KEY ( Queue ) REFERENCES CallQueue ( id ) ON DELETE CASCADE ON UPDATE CASCADE */

) ENGINE=INNODB CHARSET=UTF8 COMMENT="Calls to queue";
