Uninstalling a Moodle Plugin and forcing reinstallation

The easiest way to get moodle to re-run installation is to update the version in version.php. However, if you want to be sure it makes any schema changes etc then remove the plugin version from the mdl_config_plugins table. Note you can leave the other configuration there if required to save re-setting up the plugin.

The SQL to do this:

delete from mdl_config_plugins 
where plugin = 'plugin_name' 
and name = 'version';

For schema changes, you may need to drop the table and have it rebuild it just to ensure that the changes are made correctly.

For production deployments you should use an upgrade.php script, but this is a handy shortcut if you are developing a plugin as you really just want to iterate to the final schema version which you would then put into upgrade.php.