-- Migrate existing two-year comma-separated ranges to hyphen format.
-- Hyphen now means expandable range; comma means discrete years only.
-- Only exact "YYYY,YYYY" (with optional whitespace) pairs are converted.
-- Three-or-more-piece lists and non-year values are left untouched.

BEGIN;

UPDATE shock_brand_specs
SET "yearsRange" = regexp_replace("yearsRange", '^\s*(\d{4})\s*,\s*(\d{4})\s*$', '\1-\2')
WHERE "yearsRange" ~ '^\s*\d{4}\s*,\s*\d{4}\s*$';

UPDATE brake_brand_specs
SET "yearsRange" = regexp_replace("yearsRange", '^\s*(\d{4})\s*,\s*(\d{4})\s*$', '\1-\2')
WHERE "yearsRange" ~ '^\s*\d{4}\s*,\s*\d{4}\s*$';

UPDATE disk_brand_specs
SET "yearsRange" = regexp_replace("yearsRange", '^\s*(\d{4})\s*,\s*(\d{4})\s*$', '\1-\2')
WHERE "yearsRange" ~ '^\s*\d{4}\s*,\s*\d{4}\s*$';

UPDATE strut_brand_specs
SET "yearsRange" = regexp_replace("yearsRange", '^\s*(\d{4})\s*,\s*(\d{4})\s*$', '\1-\2')
WHERE "yearsRange" ~ '^\s*\d{4}\s*,\s*\d{4}\s*$';

UPDATE leg_brand_specs
SET "yearsRange" = regexp_replace("yearsRange", '^\s*(\d{4})\s*,\s*(\d{4})\s*$', '\1-\2')
WHERE "yearsRange" ~ '^\s*\d{4}\s*,\s*\d{4}\s*$';

COMMIT;
