Too many people with migraines are prescribed potentially addictive opiate painkillers, while too few may be getting recommended medications, a study suggests.