How to trigger plugin migration code when plugin updates?

plugin update in WordPress is basically removing it and installing again, so there is no special hook for this action.

So this hacky solution is the best one:

  • Save in options your last version
  • On init, check if current version is newer than saved version
  • If yes, perform your SQL actions