On the page where they explain how to create tables for your plugin, there’s a link to the register_activation_hook function, which is run when the plugin is activated. However, right in the first section, it says:
Note: Don’t use activation hooks (especially for multisite). Do this instead:
It’s far better to use an upgrade routine fired on admin_init, and handle that per-site, basing it on a stored option.
That links to another page, which repeats the information, but doesn’t tell you how to do this. Here’s one way. Continue reading WordPress Plugin Update and Install Functions