We identified the diuretics and agents that act on the renin‐angiotensin system as the contraindicated medications for migraine and migraine with aura, and BLM, C12orf76, GPATCH4, PAM, SERPINC were found as the targeted genes of contraindicated drugs for migraine and ALMS1, GPATCH4, NCF2, SLC12A1, ZKSCAN8P1 for migraine with aura, providing new clues for the preventive strategies for migraine and its subtypes. This evidence concerns the gene ALMS1 and migraine with aura.