-- =============================================================================
-- Set display order for the apparel SIZE lookup values (XS -> XXXXL) in lookup_data.
--
-- lookup_order previously defaulted to 0 for these rows, so they sorted
-- alphabetically (L, M, S, XL, XS, XXL, ...) instead of by size progression.
--
-- Scope: rows in lookup_data whose lookup_label is one of
--        XS, S, M, L, XL, XXL, XXXL, XXXXL.
--
-- Run PER ENVIRONMENT (dev / staging / prod). Never run against prod from a local box.
-- Review the row counts printed before COMMIT.
-- =============================================================================

BEGIN;

UPDATE lookup_data SET lookup_order = CASE lookup_label
    WHEN 'XS'    THEN 1
    WHEN 'S'     THEN 2
    WHEN 'M'     THEN 3
    WHEN 'L'     THEN 4
    WHEN 'XL'    THEN 5
    WHEN 'XXL'   THEN 6
    WHEN 'XXXL'  THEN 7
    WHEN 'XXXXL' THEN 8
END
WHERE lookup_label IN ('XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL', 'XXXXL');

COMMIT;
