The weird thing is that after the migraine is over I can actually remember most of what happened during it, so somehow things are still finding their way into my long term memory - though it's mostly just conversations like "hey, I'm having a migraine, I'm going to lie down for a few minutes, because I'm having a migraine, it's affecting my memory, so I'm going to lie down, I think this migraine is affecting my memory" "ok dude, take a break" "woah, how did you know I need a break? I was just thinking that I should take a break, because I'm having a migraine, and it's probably affecting my memory. Did you know I get migraines that affect my memory? I should probably go lie down"...
[1] http://qz.com/511920/a-tumor-stole-every-memory-i-had-this-i...
Perhaps your migraines sometimes trigger a waking dream state, or something functionally equivalent, where you're still seeing the real world instead of one your mind has created, but parts of your brain that are used to interpret your sensory input have switched to dream-mode.
[1] Not formally diagnosed as migraines (migraines don't typically cause a single headache that never goes away for years, but just fluctuates in intensity), but my sister has been so I suspect there is a link.
Weirdly I can still code easily, even keeping in my head high level module interactions and abstractions, to low level implementation details, but I'll occasionally stop, stare at a word, convinced that it's spelt wrong, google it and see its correct, and go back and stare at it - because it just feels wrong.
When I've reached this point, I know it's time to break!
The longest its ever lasted was about 1.5 hours. Usually about the time the freight-train of pain arrives, everything goes back to normal. Of course then I'm in no mood to read anything anyway.