I've never heard of nitroglycerin being used to treat migraine, but glad that it worked.
But if it keeps on, and sorry to tell you this, but you probably should see a doctor ASAP. It could be the sign of a coming stroke, since it is sudden and very painful. I started with a sudden very different migraine than any I had ever had before. It turned out that within 3 weeks, longer than usual as a gap in time, I had a full carotid artery dissection stroke.