I've been working on a theory that I get migraine's as a result of bad posture due to desk work and stress. I've always carried stress in my shoulders and upper back where I also have sore muscles due to poor posture. My theory goes is that the bad chemistry associated with stress builds up in my upper back til it hits a breaking point and it all gets dumped into my brain and I have a migraine.
So I included a bunch of exercises that prevent the build up of stress chemicals in my upper into my routine that I do and I'm having a lot of success. In the past few years I've only gotten migraines during stressful periods where I've stopped doing my exercises for a few weeks and I'm currently on my longest streak (nearly a year) without having a migraine because I've been pretty diligent as there's been no shortage of stress this year.
My key exercises are:
Chin ups: 6 rounds of 8-10 reps of varying grips with a chair. It's important to get a lot of reps to make sure your getting good blood flow into the entire upper back.
DDP style yoga, I include the above chin ups into a yoga routine, I do warrior poses between rounds of chin ups
Door frame stretches (5 min), they don't look like much but don't underestimate them. Just doing 5 minutes is challenging and rewarding
Yoga block back stretch (5-10), a very intense counter stretch to hunching over a key board all day.
The best thing I've ever done for posture is power lifting, because you'll destroy your body with anything less than excellent posture so you have to take the time to understand posture really well and then all your posture muscles get really strong and it becomes easy.