[
  {
    "type": "create_table",
    "description": "Create seller marketing analytics table",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'seller_marketing_analytics'",
    "sql": "CREATE TABLE `seller_marketing_analytics` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `trigger_id` int(10) unsigned DEFAULT NULL COMMENT 'References seller_marketing_triggers.id',\n  `blast_id` int(10) unsigned DEFAULT NULL COMMENT 'References seller_marketing_blasts.id',\n  `message_id` int(10) unsigned NOT NULL COMMENT 'References seller_marketing_messages.id',\n  `type` enum('trigger','blast') NOT NULL COMMENT 'Analytics type',\n  `date` date NOT NULL COMMENT 'Analytics date',\n  `recipient_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number of recipients',\n  `sent_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number successfully sent',\n  `delivered_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number delivered (if tracking available)',\n  `failed_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number failed',\n  `opt_out_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number who opted out',\n  `response_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number who responded (future feature)',\n  `conversion_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number who made purchase (future feature)',\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `unique_trigger_date` (`trigger_id`,`date`),\n  UNIQUE KEY `unique_blast_date` (`blast_id`,`date`),\n  KEY `idx_message_date` (`message_id`,`date`),\n  KEY `idx_type_date` (`type`,`date`),\n  CONSTRAINT `fk_analytics_trigger` FOREIGN KEY (`trigger_id`) REFERENCES `seller_marketing_triggers` (`id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_analytics_blast` FOREIGN KEY (`blast_id`) REFERENCES `seller_marketing_blasts` (`id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_analytics_message` FOREIGN KEY (`message_id`) REFERENCES `seller_marketing_messages` (`id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Analytics data for seller marketing campaigns'"
  }
]