Resetting hook_update_N module schema

While I’m developing and testing a hook_update_N() function for my module, there are several ways to reset the schema_version in the system database table.


The manual way:

update system set schema_version=0 where name='mymodule';

Or the automated way…throw a Drupal Update Exception:

/**
 * Comment on what this update does
 */
function mymodule_update_7001(&$sandbox) {
  throw new DrupalUpdateException('Ignore error while testing update.');
}

Caveat: this is only useful for testing prior to actual committing to the changes, once you make database schema or node changes, throwing the exception could cause your database to corrupt.