-- ---------------------------------------------------------------------------
-- Migration: track which egg GRADE a usage/sale line drew from
-- ---------------------------------------------------------------------------
-- schema.sql already carries these for FRESH installs. Run this ONCE against
-- an EXISTING database (paste into phpMyAdmin's SQL tab, or
-- `mysql -u <user> -p <db> < sql/migration-2026-07-egg-grade-tracking.sql`).
-- Existing rows default to 'mixed' (the pooled-stock behavior every row had
-- before grades existed), so nothing already recorded changes meaning.
-- ---------------------------------------------------------------------------

ALTER TABLE egg_usage
  ADD COLUMN grade ENUM('gradeA','gradeB','cracked','dirty','rejected','mixed') NOT NULL DEFAULT 'mixed' AFTER reason;

ALTER TABLE sale_items
  ADD COLUMN grade ENUM('gradeA','gradeB','cracked','dirty','rejected','mixed') NULL AFTER sort_order;
