-- Historico de disparos de alertas de prazo de tarefas para evitar repeticao excessiva.

CREATE TABLE IF NOT EXISTS `wpjy_tarefas_alert_dispatches` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `id_tarefa` BIGINT UNSIGNED NOT NULL,
    `user_id` BIGINT UNSIGNED NOT NULL,
    `signature_hash` CHAR(40) NOT NULL,
    `payload_json` JSON NULL DEFAULT NULL,
    `sent_at` DATETIME NOT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_tarefa_user_sent` (`id_tarefa`, `user_id`, `sent_at`) USING BTREE,
    INDEX `idx_signature_sent` (`signature_hash`, `sent_at`) USING BTREE
)
COLLATE='utf8mb4_0900_ai_ci'
ENGINE=InnoDB
;
