-- Создание таблицы contractors_pending для модерации записей контрагентов
CREATE TABLE IF NOT EXISTS `contractors_pending` (
  `id` VARCHAR(36) PRIMARY KEY,
  `name` VARCHAR(100) NOT NULL,
  `category` VARCHAR(50) NOT NULL,
  `contract_number` VARCHAR(100),
  `phone` VARCHAR(20) NOT NULL,
  `email` VARCHAR(100),
  `web_link` VARCHAR(500),
  `manager_name` VARCHAR(100),
  `manager_phone` VARCHAR(20),
  `manager_email` VARCHAR(100),
  `comment` TEXT,
  `status` VARCHAR(20) NOT NULL DEFAULT 'pending',
  `target_id` VARCHAR(36),
  `created_by` VARCHAR(36),
  `reviewed_by` VARCHAR(36),
  `reviewed_at` TIMESTAMP NULL,
  `rejection_reason` TEXT,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_status` (`status`),
  INDEX `idx_target_id` (`target_id`),
  INDEX `idx_created_by` (`created_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
