CREATE TABLE ContactCentreAssignment
(
    id BIGINT UNSIGNED DEFAULT NULL AUTO_INCREMENT,
    ActivityId BIGINT UNSIGNED NOT NULL COMMENT "Activity id linked to this assignment",
    AgentId BIGINT UNSIGNED DEFAULT NULL COMMENT "Agent to which the activity is assigned, if any",
    Action ENUM ( 'Accepted', 'Completed', 'Timeout', 'Failed' ) COMMENT "What happened",
    Timestamp BIGINT UNSIGNED DEFAULT NULL COMMENT "Unix timestamp when the assignment happened",
    PRIMARY KEY ( id ),
    KEY ( ActivityId ),
    KEY ( AgentId ),
    FOREIGN KEY ( ActivityId ) REFERENCES ContactCentreActivity ( id ) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB CHARSET=UTF8;