O'Reilly logo

Drupal 8 Module Development by Daniel Sipos

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Update hooks

At the beginning of this chapter, we defined two tables using hook_schema(), which got installed together with the module. To reiterate, if the module had already been installed, we could have triggered the schema installation using the drupal_install_schema() function. However, what if we needed to add another column later on, say to the teams table? Our module is installed, and so is the schema; so, we cannot exactly uninstall it on production just for triggering the schema creation again, not to mention losing the data. Luckily, there is a system in place for this, in the name of update hooks--hook_update_N()--where N represents the schema version. These are sequentially named hook implementations that go inside the module ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required