In my experience it is hard to stop a migraine quickly once it sets in. You may however be able to mitigate the pain. For me, I always prefer to vape a high CBD ratio pen if I experience this type of pain. I will use a 3:1 or a 1:1 vape oil cartridge or a flower such as cannatonic or ACDC. This has proven effective for helping to manage pain. That said, many people do well with a higher THC product. One woman I spoke to recently take 10mg lozenges for her migraines and is fully functional. Everyone is different, so it is a matter of experimenting with what works for you.
In terms of preventing migraines, there is a lot you can do besides cannabis to help prevent them including sleeping well, taking vitamin B everyday, eating healthy, cutting out products such as wine and soy and so on. We started HelloMD because I was able to prevent my migraines after suffering for 25 years. My regime includes a high CBD to THC ratio tincture every day. It started to prevent them after 6 months of taking it.