-- Legacy rows use kebab-case IDs (e.g. barbell-bench-press) but the app
-- catalog and FKs will reference camelCase IDs (benchPress). Merge the
-- Banyard-curated MVT values into the camelCase catalog rows, then drop
-- the 5 legacy rows. Safe now because nothing downstream references them
-- (exercise_entries / load_velocity_profile are empty).

-- 1. Copy curated MVT + mcv_at_1rm_mps onto the corresponding camelCase
-- catalog rows.
UPDATE public.exercise_metadata AS target
SET
  default_mvt_mps = src.default_mvt_mps,
  mcv_at_1rm_mps  = src.mcv_at_1rm_mps,
  transfer_parent_id     = COALESCE(target.transfer_parent_id,     src.transfer_parent_id),
  transfer_coefficient   = COALESCE(target.transfer_coefficient,   src.transfer_coefficient)
FROM (VALUES
  ('benchPress',    'barbell-bench-press'),
  ('squat',         'barbell-back-squat'),
  ('deadlift',      'barbell-deadlift'),
  ('bentOverRow',   'barbell-bent-row'),
  ('militaryPress', 'barbell-overhead-press')
) AS m(new_id, old_id)
JOIN public.exercise_metadata AS src ON src.exercise_id = m.old_id
WHERE target.exercise_id = m.new_id;

-- 2. Remove the 5 legacy rows
DELETE FROM public.exercise_metadata
WHERE exercise_id IN (
  'barbell-bench-press',
  'barbell-back-squat',
  'barbell-deadlift',
  'barbell-bent-row',
  'barbell-overhead-press'
);
