[
  {
    "type": "create_table",
    "description": "Create staff_chat_read_receipts table for per-channel high water mark read tracking",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'staff_chat_read_receipts'",
    "sql": "CREATE TABLE `staff_chat_read_receipts` (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n  `channelId` int(10) unsigned NOT NULL,\n  `employeeId` int(10) unsigned NOT NULL,\n  `lastReadMessageId` bigint(20) unsigned NOT NULL,\n  `readAt` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `uk_channel_employee` (`channelId`, `employeeId`),\n  KEY `idx_employeeId` (`employeeId`),\n  CONSTRAINT `fk_staff_chat_read_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 per-channel read position per user (ADR-2 high water mark)'"
  }
]
