-- Migration: Add unique index on order_number in product_orders
-- Date: 2026-03-26
-- Purpose: Prevent duplicate order numbers caused by concurrent requests
--          generating the same timestamp-based order number.
-- Note: Run only after confirming no duplicate order_numbers exist.
--       Use the query below to check first:
--       SELECT order_number, COUNT(*) c FROM product_orders GROUP BY order_number HAVING c > 1;

ALTER TABLE product_orders
  ADD UNIQUE INDEX idx_order_number_unique (order_number);
