2

In Drupal 7 we could edit the system table to set a module a version back to let the hook_update_n run again.

In Drupal 8 there is no system table.

Where can I find what version of the module is installed so I can change this and make sure the update hook is run again?

This is useful while developing hook_update_N() of my module so I can test this.

0
6

To store/get the version information for a module use the global functions:

drupal_set_installed_schema_version()
drupal_get_installed_schema_version()

For example set a new version for mymodule with drush:

drush ev "drupal_set_installed_schema_version('mymodule', '8123')"

Print the version with drush, in this example for the module comment:

drush ev "var_dump(drupal_get_installed_schema_version('comment'))"

The functions are defined in schema.inc. Here you can see how to access the key_value table through the keyvalue api, if you want to use your own code:

/**
 * Updates the installed version information for a module.
 *
 * @param string $module
 *   A module name.
 * @param string $version
 *   The new schema version.
 */
function drupal_set_installed_schema_version($module, $version) {
  \Drupal::keyValue('system.schema')->set($module, $version);
  // Reset the static cache of module schema versions.
  drupal_get_installed_schema_version(NULL, TRUE);
}
2

Turns out there is now a key_value table

This table contains:

collection, name, value

Where value is the installed version. enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.