When you install or upgrade a module, you may need to change the database structure or add some new data in current table. Magento 2 provide you some classes which you can do all of them.

  • InstallSchema – This class will execute when the module is installed to setup the database structure.
  • InstallData – This class will execute when the module is installed to initial the data for database table.
  • UpgradeSchema – This class will execute when the module is upgraded to setup the database structure.
  • UpgradeData – This class will execute when the module is upgraded to add/remove data from table.

Now we want to add new column in Magento Structure. For this we need to create the InstallSchema file.

Create the InstallSchema.php in the path app/code/[Vendor Name]/[Module Name]/Setup/InstallSchema.php

After adding this column in the setup file, run the following command:
php bin/magento setup:upgrade

After installing the module, you can see the field in the Sales_order table.