Its a controversial subject and as a heavy coffee drinker one that interests me - a lot of studies have been carried out on the subject:
https://www.sciencedaily.com/releases/2009/08/090813083455.htm
https://americanmigrainefoundation.org/understanding-migraine/caffeine-and-migraine/