Add a table to a database

Commerce has a special mechanism that enables you to create database tables, modify existing ones, and even add some data into them - like setup data, which has to be added when a module is installed. This mechanism allows those changes to be transferable between different installations.

Rather than doing manual SQL operations repeatedly when reinstalling the system, developers create an install (or upgrade) script that contains the data. The script runs every time a module is installed.

Who is this video for?

  • Developers

Video content

  • Create a module
  • Create InstallSchema Script
  • Create InstallData Script
  • Add new module and verify that a table with data was created
  • Create an UpgradeSchema script
  • Create an UpgradeData script
  • Run upgrade scripts and verify that the table has changed

Useful resources

On this page