-- Создание таблицы inventory_pending для модерации записей инвентаря
CREATE TABLE IF NOT EXISTS `inventory_pending` (
  `id` VARCHAR(36) PRIMARY KEY,
  `name` VARCHAR(100) NOT NULL,
  `category` VARCHAR(20) NOT NULL,
  `quantity` DECIMAL(10,2) NOT NULL,
  `unit` VARCHAR(20),
  `location` VARCHAR(100) NOT NULL,
  `comment` TEXT,
  `weight_per_unit` DECIMAL(10,3),
  `manufacturer` VARCHAR(100),
  `model` VARCHAR(100),
  `serial_number` VARCHAR(100),
  `ordering_link` VARCHAR(500),
  `article_number` VARCHAR(100),
  `status` VARCHAR(20) NOT NULL DEFAULT 'pending',
  `target_id` VARCHAR(36),
  `created_by` VARCHAR(36) NOT NULL,
  `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;
