The reason throwing up relieves migraines or reduces the migraine pain is because when you throw up the act of throwing up reduces blood flow to pain sensitized vessels.
When the blood flow to the sensitized vessels is reduced then your blood pressure goes down some which in turn leads to the relief of the migraines.
However the pain relief of the migraine from throwing up is usually only temporary and the migraine pain will usually return eventually.
If you're having migraines you should take some pain reliever such as Aspirin or other NSAID pain relieving medication.
Applying a warm compress or even a cold compress can sometimes help relieve migraines as well.
If the migraines continue longer than a few days or the migraines get worse then you should see a doctor or go to a walk in clinic to figure out what is going on.