CREATE TABLE IF NOT EXISTS `wpjy_app_notification_ack_logs` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `notification_id` BIGINT UNSIGNED NOT NULL,
  `broadcast_id` BIGINT UNSIGNED NULL,
  `user_id` BIGINT UNSIGNED NOT NULL,
  `action` VARCHAR(40) NOT NULL DEFAULT 'acknowledged',
  `source` VARCHAR(40) NOT NULL DEFAULT 'manual',
  `meta_json` JSON NULL,
  `ack_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_app_notification_ack_unique` (`notification_id`, `user_id`, `action`),
  KEY `idx_app_notification_ack_broadcast` (`broadcast_id`, `action`, `ack_at`),
  KEY `idx_app_notification_ack_user` (`user_id`, `action`, `ack_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
