CREATE TABLE WebCDR
(
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    cdr_id BIGINT UNSIGNED DEFAULT NULL,
    missed_id BIGINT UNSIGNED DEFAULT NULL,
    Zone BIGINT UNSIGNED DEFAULT NULL,
    Node BIGINT UNSIGNED DEFAULT NULL,
    Person BIGINT UNSIGNED DEFAULT NULL,
    Source VARCHAR(50) DEFAULT NULL,
    Destination VARCHAR(50) DEFAULT NULL,
    StartTime BIGINT UNSIGNED NOT NULL DEFAULT 0,
    Name VARCHAR(15) DEFAULT NULL,
    Duration INT DEFAULT NULL,
    Inbound TINYINT DEFAULT 0,
    Weekday TINYINT DEFAULT NULL,
    sip_callid VARCHAR(255) DEFAULT NULL,

    /* Allow fun stats about countries */

    Country VARCHAR(4) DEFAULT NULL,
    Exch VARCHAR(10) DEFAULT NULL,
    PRIMARY KEY ( id,StartTime ),
    KEY ( Node ),
    KEY ( Person ),
    KEY ( Zone ),
    KEY ( cdr_id ),
    KEY ( missed_id ),
    KEY ( Source ),
    KEY ( Destination ),
    KEY ( Zone, StartTime, Inbound ),
    KEY ( Zone,StartTime )
    /* ,                           FOREIGN KEY ( Node ) REFERENCES nodes ( id ) ON DELETE CASCADE ON UPDATE CASCADE */

) ENGINE=INNODB CHARSET=UTF8 COMMENT="VoIP preparsed CDRs for fast listings";
