Allah never commanded the Muslims to fight before they migrated to Medina. Instead the Prophet (pbuh) was commanded many times to remind the people of the truth.
"So remind, if the reminder should benefit" - Quran 87:9
The longer Muhammad (pbuh) preached, the more people accepted Islam. Although the Muslims were being persecuted in Mecca, they still had enough protection for the message to be conveyed to the public. It was only after Abu Talib's death and a assassination attempt, when he (pbuh) and the rest of the Muslims had to end this kind of preaching and migrate.
If you look at the story of other Messengers such as Nuh (pbuh), or Musa (pbuh), then you will see the same methodology. First the messengers warn the disbelievers for a period of time (determined by Allah), and then the disbelievers (if they did not accept the message) face the consequences of their disbelief immediately afterward.