[
  {
    "type": "create_table",
    "description": "Create seller marketing customer log table",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'seller_marketing_customer_log'",
    "sql": "CREATE TABLE `seller_marketing_customer_log` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `customer_id` int(10) unsigned NOT NULL COMMENT 'References customers.id',\n  `phone` varchar(15) NOT NULL COMMENT 'Customer phone number',\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  `message_content` text NOT NULL COMMENT 'Actual message sent to customer',\n  `sent_at` timestamp NOT NULL COMMENT 'When message was sent',\n  `status` enum('sent','delivered','failed','opt_out') NOT NULL COMMENT 'Message status',\n  `provider_id` varchar(255) DEFAULT NULL COMMENT 'Provider message ID',\n  `response_received` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Whether customer responded',\n  `response_content` text DEFAULT NULL COMMENT 'Customer response (if any)',\n  `conversion_tracked` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Whether conversion was tracked',\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  PRIMARY KEY (`id`),\n  KEY `idx_customer_sent` (`customer_id`,`sent_at`),\n  KEY `idx_phone` (`phone`),\n  KEY `idx_trigger_id` (`trigger_id`),\n  KEY `idx_blast_id` (`blast_id`),\n  KEY `idx_message_id` (`message_id`),\n  KEY `idx_status` (`status`),\n  CONSTRAINT `fk_log_trigger` FOREIGN KEY (`trigger_id`) REFERENCES `seller_marketing_triggers` (`id`) ON DELETE SET NULL,\n  CONSTRAINT `fk_log_blast` FOREIGN KEY (`blast_id`) REFERENCES `seller_marketing_blasts` (`id`) ON DELETE SET NULL,\n  CONSTRAINT `fk_log_message` FOREIGN KEY (`message_id`) REFERENCES `seller_marketing_messages` (`id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Log of all messages sent to customers'"
  }
]