How to Re-Run Updates In Drupal

This is how you can run a Drupal update again

Photo by Markus Winkler on Unsplash

When working on a hook update in Drupal, we likely have to run it multiple times to test it properly. While in Drupal 7 we could just update the schema_version column in the table system, from Drupal 8 and above is not that simple.

Luckily, we can do it with just one drush command:

drush ev "\Drupal::service('update.update_hook_registry')->setInstalledVersion('module_name', 9501);"

In the command above, replace module_name with the name of your module and 9501 with the previous hook_update id to the one you want to run.

πŸ‘‰ Find out more about me here: https://sergioguardiola.net πŸ”₯

--

--

Sergio Guardiola Herrador

I write articles in English and Spanish, mostly about programming, technology, travel, money, investing. You can find me here: https://sergioguardiola.net