Cherries have a lot of potassium and some magnesium and calcium as well. Potassium has been linked tenuously to headache and migraine reduction. More importantly cherries have antioxidants cyanidin and anthocyanin which are anti-inflammatory and can have a pain reducing effect.
Sources