How to Get the Database of Your Plugin Installed During Plugin Installation

In case your plugin has database that must be installed during the installation of the plugin, this is what you must do:

  • Create a directory named install. The name of this directory must be exactly install and must not change.

  • Put the install directory inside your plugin's directory. For example, if your plugin's directory is my_plugin, then you must put the install directory inside the my_plugin directory like this: my_plugin/install.

  • The database which you want your plugin to install should be in an SQL file with a .sql extension and should be named install.sql.

  • Put the install.sql file inside the install directory like so: my_plugin/install/install.sql.

  • That will be it. During installation of your plugin, the install.sql will be installed and will be deleted after the installation.