

-- Review queue table
CREATE TABLE IF NOT EXISTS `review_queue` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `order_id` INT NOT NULL,
  `customer_email` VARCHAR(255) NOT NULL,
  `customer_name` VARCHAR(255) DEFAULT NULL,
  `product_id` INT NULL,
  `product_name` VARCHAR(255) NULL,
  `product_image` TEXT NULL,
  `type` ENUM('service','product') NOT NULL,
  `status` ENUM('pending','sent') NOT NULL DEFAULT 'pending',
  `created_at` DATETIME NOT NULL,
  `sent_at` DATETIME NULL,
  INDEX (`order_id`),
  INDEX (`status`),
  INDEX (`customer_email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- (Optional) Seed data for testing admin logs
INSERT INTO `review_queue` 
(`order_id`, `customer_email`, `customer_name`, `product_id`, `product_name`, `type`, `status`, `created_at`, `sent_at`) VALUES
(1001, 'alice@example.com', 'Alice', NULL, NULL, 'service', 'sent',   NOW() - INTERVAL 2 DAY, NOW() - INTERVAL 1 DAY),
(1001, 'alice@example.com', 'Alice', 200, 'Sample Product A', 'product', 'sent', NOW() - INTERVAL 2 DAY, NOW() - INTERVAL 1 DAY),
(1002, 'bob@example.com', 'Bob', NULL, NULL, 'service', 'pending', NOW(), NULL);
