[
  {
    "type": "create_table",
    "description": "Create staff_chat_event_outbox table for reliable async Ably publishing (ADR-7 outbox pattern)",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'staff_chat_event_outbox'",
    "sql": "CREATE TABLE `staff_chat_event_outbox` (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n  `eventType` varchar(50) NOT NULL COMMENT 'message.created, reaction.added, etc.',\n  `channelId` int(10) unsigned NOT NULL,\n  `payload` json NOT NULL,\n  `status` enum('pending','processing','completed','failed') NOT NULL DEFAULT 'pending',\n  `attempts` tinyint(3) unsigned NOT NULL DEFAULT 0,\n  `lastAttemptAt` timestamp NULL DEFAULT NULL,\n  `errorMessage` text DEFAULT NULL,\n  `createdAt` timestamp NOT NULL DEFAULT current_timestamp(),\n  `processedAt` timestamp NULL DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  KEY `idx_status_createdAt` (`status`, `createdAt`),\n  KEY `idx_channelId` (`channelId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Staff Chat Ably event outbox for reliable async publishing'"
  }
]
