-- Phase 3: record which unit a sale line was sold in, so stock deducts in BASE
-- units while the receipt shows the chosen unit. Additive/nullable — legacy rows
-- default to factor 1 (base_qty = qty), preserving existing behavior and reports.

ALTER TABLE `order_items` ADD COLUMN `unit_id` BIGINT NULL DEFAULT NULL;
ALTER TABLE `order_items` ADD COLUMN `unit_name` VARCHAR(255) NULL DEFAULT NULL;
ALTER TABLE `order_items` ADD COLUMN `conversion_factor` DECIMAL(12,3) NULL DEFAULT 1.000;
ALTER TABLE `order_items` ADD COLUMN `base_qty` INT NULL DEFAULT NULL;
