Drupal - How do I re-run updates (change module schema version)?

While accessing state directly works, you can also just use the API: drupal_set_installed_schema_version(). Which actually exists unchanged at least since 4.7, as visible on the linked documentation page. Probably one of the few API functions that existed for so long ;)

To set it from drush:

drush ev "drupal_set_installed_schema_version('fillpdf', 8012)"

Note: In Drupal 7 you need to add extra include 'includes/install.inc';.


Drupal 8 now uses the keyvalue service to store information about the schema version. This is the same API the State API itself uses.

Value information is serialized when stored in the database, so using a direct SQL query is sub-optimal. Instead, use drush php-eval (or a script that bootstraps Drupal, if you don't have Drush) to execute the following:

<?php
  \Drupal::keyValue('system.schema')->set('fillpdf', (int) 8102);
?>

Change fillpdf and 8102 to your module name and desired schema version, respectively.

The Drush form of this command is:

drush ev "\Drupal::keyValue('system.schema')->set('fillpdf', (int) 8102)";

Tags:

8