-- Step 30: Add customer message translation support
-- Adds messageTranslation column to store auto-translated or on-demand translated messages
-- Adds rate-limiting table to prevent OpenAI API abuse

ALTER TABLE `sessionCustomerRequests`
  ADD COLUMN `messageTranslation` varchar(500) DEFAULT NULL AFTER `message`;

CREATE TABLE `messageTranslationRequests` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `vendorId` varchar(50) NOT NULL,
  `customerId` int(11) NOT NULL DEFAULT 0,
  `requestedAt` int(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_vendor_time` (`vendorId`,`requestedAt`),
  KEY `idx_customer_time` (`customerId`,`requestedAt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
