There is some very limited research that suggests CBD oil could help prevent migraines, but it’s still in early stages. If CBD oil is something you’ve thought about taking, it may help.
A more well established fix for the pain migraines cause is THC. These days, most strains at dispensaries have pretty high THC content. There’s no clear link that shows THC prevents migraines, though.
Your best bet here is using THC as a pain killer when you feel a migraine coming on. Other than that, there is some anecdotal evidence that cannabis might help prevent migraines, but this is not well studied, and may require some experimentation.