CREATE TABLE SMSCommunication
(
    Mobile VARCHAR(35) DEFAULT NULL,
    Provider VARCHAR(25) DEFAULT NULL,
    Supplier VARCHAR(15) DEFAULT NULL,
    Message TEXT DEFAULT NULL COMMENT "Message or text to be sent to mobile",
    Object TEXT DEFAULT NULL,
    LockId CHAR(32) DEFAULT NULL,
    ConfirmId VARCHAR(48) DEFAULT NULL COMMENT "Supplier confirmation code",
    id BIGINT NOT NULL AUTO_INCREMENT,
    ts BIGINT UNSIGNED DEFAULT NULL COMMENT "Timestamp when the message was sent to the supplier",
    LaunchId BIGINT UNSIGNED DEFAULT NULL,
    SMSNode BIGINT UNSIGNED DEFAULT NULL COMMENT "SMS Node ID that is associate with this mobile phone number, optionnal",
    FromSmsCode VARCHAR(16) DEFAULT NULL,
    SendTs BIGINT UNSIGNED DEFAULT NULL COMMENT "Earliest time at which we can send the message to the supplier",
    Priority SMALLINT UNSIGNED DEFAULT 0 COMMENT "Priority of this SMS relative to other SMSes, the higher the better",

    PRIMARY KEY ( id ),

    KEY ( ConfirmId, LockId, LaunchId ),

    /* When cancelling a launch */
    KEY ( LockId ),

    /* Reading rows after lock */
    KEY ( ConfirmId,LockId,SendTs ),

    /* When selecting a row for work */
    KEY ( Mobile ),
    KEY ( ts )

) ENGINE=INNODB CHARSET=UTF8 COMMENT="Table for tracking SMS communications";
