How to Uninstall the Database of Your Plugin During Deletion of the Plugin
In case admin user of your plugin is deleting your plugin and you want your plugin to uninstall its database, this is what you must do:
-
Create a directory named
install. The name of this directory must be exactlyinstalland must not change.
-
Put the
installdirectory inside your plugin's directory. For example, if your plugin's directory ismy_plugin, then you must put theinstalldirectory inside themy_plugindirectory like this:my_plugin/install.
-
You must have an SQL file with a .sql extension which contains the various statements to drop tables and/or delete rows or perform other operations on the database. This SQL should be named
uninstall.sql.
-
Put the
uninstall.sqlfile inside theinstalldirectory like so:my_plugin/install/uninstall.sql.
-
That will be it. During the deletion of your plugin, the
uninstall.sqlwill be run to execute the statements in it on the database.







