There could be many reasons your friend gets migraine attacks, but please, don't call a suspected cause "mental." Migraine disease is a real neurological disorder. Stress can play a role in attacks, but lots of people get stressed--only people with our unusually-wired brains get excruciatingly painful migraine attacks. The attacks are bad enough, but you may not undertsand that being told "it's mental" is insulting, belittling and demeaning to the person suffering.
Stress could lower your friend's resistance to an attack, but there may be environmental triggers at school that aren't at home. Is the school lit with old-fashioned fluorescent lights (the kind that hum when you turn them on)? Those lights (with what they call "magnetic ballast" driving the electricity through the tubes) flicker at a rate your eye can't see, but a certain part of your brain can. That part of your brain may be able to 'ignore' the flicker, but your friend's brain can't and gets overstimulated. There might be scents at school (such as industrial cleaners or solvents in carpeting or flooring) that aren't at home. The noise level is different at school. What your friend eats for lunch at school may be different.
If your friend isn't seeing a neurologist, I strongly recommend his family doctor write him a referral to one.