@pfefferle Whatever you do: Do not (only) rely on hooks that only trigger when using the standard, internal updating mechanism like https://developer.wordpress.org/reference/hooks/upgrader_process_complete/ There are way too many sites out there that update differently (manual, FTP, composer etc.) Generally I'd say have an autoloaded option that stores the current version you compare with the current version. On mismatch start migration. Also be careful to handle downgrades or other broken states and not solely rely on version info in the option
@pfefferle Well it basically is a single "if" comparing a string with an autoloaded option. I'd say the performance impact will be almost impossible to see even in a benchmark. If you've reached that level of performance optimization I really envy your codebase! 😉
@gmazzap@pfefferle But if the flag is stored in a DB option then never rely on the flag alone because people do "crazy" stuff like downgrade plugin versions . So use it to trigger the migration but then re-check the pre-conditions again. Also make sure that if you run multiple upgrades at once when people do huge version jumps you do them in the right order. I've seen plugins wrecking themselves badly by not paying attention to this. And I've probably missed some more potential issues 🙃
@kraftner@pfefferle Also mind multisite. When plugins are installed network-wide, the upgrade/installation process might be seen on only one site (the first hit), but options are site-specific. So, really, the best option is to check if what you expect is there with a simple flag, and if not, do it, then set the flag.
1. Have a thing like `%%VERSION%%` in: plugin headers, README.txt|md, package.json, and in the main plugin file have a constant `define('MYPLUGIN_VERSION', '%%VERSION%%')`