-- Histórico de disparos de alertas de metas para evitar repetição excessiva.

CREATE TABLE IF NOT EXISTS `wpjy_metas_alert_dispatches` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `alert_id` BIGINT UNSIGNED NOT NULL,
    `meta_id` 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_alert_meta_user_sent` (`alert_id`, `meta_id`, `user_id`, `sent_at`) USING BTREE,
    INDEX `idx_signature_sent` (`signature_hash`, `sent_at`) USING BTREE
)
COLLATE='utf8mb4_0900_ai_ci'
ENGINE=InnoDB
;
