[
  {
    "type": "create_table",
    "description": "Create staff_chat_messages table for Staff Chat message storage with audit support",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'staff_chat_messages'",
    "sql": "CREATE TABLE `staff_chat_messages` (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n  `channelId` int(10) unsigned NOT NULL,\n  `typeNum` varchar(10) NOT NULL,\n  `senderEmployeeId` int(10) unsigned DEFAULT NULL COMMENT 'NULL = system message',\n  `senderType` enum('employee','system') NOT NULL DEFAULT 'employee',\n  `content` text NOT NULL,\n  `contentOriginal` text DEFAULT NULL COMMENT 'Before edit, for audit',\n  `clientMessageId` varchar(36) DEFAULT NULL COMMENT 'UUID for deduplication',\n  `systemSourceType` varchar(50) DEFAULT NULL COMMENT 'For system messages: task, note, etc.',\n  `systemSourceId` int(10) unsigned DEFAULT NULL COMMENT 'For system messages: ID of source entity',\n  `isEdited` tinyint(1) NOT NULL DEFAULT 0,\n  `isDeleted` tinyint(1) NOT NULL DEFAULT 0,\n  `deletedAt` timestamp NULL DEFAULT NULL,\n  `createdAt` timestamp NOT NULL DEFAULT current_timestamp(),\n  `editedAt` timestamp NULL DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `uk_clientMessageId` (`clientMessageId`),\n  KEY `idx_channelId_createdAt` (`channelId`, `createdAt`),\n  KEY `idx_channelId_id` (`channelId`, `id`) COMMENT 'For pagination by message ID',\n  KEY `idx_typeNum_senderEmployeeId` (`typeNum`, `senderEmployeeId`),\n  CONSTRAINT `fk_staff_chat_message_channel` FOREIGN KEY (`channelId`) REFERENCES `staff_chat_channels` (`id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Staff Chat message history with edit tracking'"
  }
]
