-- Items used in service orders (parts, services)
CREATE TABLE IF NOT EXISTS service_order_items (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  order_id BIGINT UNSIGNED NOT NULL,
  product_id BIGINT UNSIGNED NULL,
  descricao VARCHAR(255) NULL,
  quantidade DECIMAL(12,3) NOT NULL DEFAULT 1,
  valor_unit_cents BIGINT NOT NULL DEFAULT 0,
  subtotal_cents BIGINT NOT NULL DEFAULT 0,
  created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
  INDEX idx_soi_order (order_id),
  INDEX idx_soi_product (product_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;