CREATE TABLE RepetitionWorker
(
    id BIGINT UNSIGNED DEFAULT NULL,
    Node BIGINT UNSIGNED NOT NULL,
    FieldName VARCHAR(255) NOT NULL,
    ScheduledTs BIGINT UNSIGNED DEFAULT NULL,
    LockId CHAR(32) DEFAULT NULL,
    ExecutionTs BIGINT UNSIGNED DEFAULT NULL,
    isDone TINYINT UNSIGNED DEFAULT 0,
    isFailed TINYINT UNSIGNED DEFAULT 0,
    PRIMARY KEY ( id ) AUTO_INCREMENT,
    KEY ( LockId ),

    /* Reading rows after lock */

    UNIQUE KEY ( Node,FieldName,ScheduledTs )
    /* Can only exist once. */

) ENGINE=INNODB CHARSET=UTF8 COMMENT="Table for tracking repetitive tasks to be regularly executed";
