Confused about hook_update_n I am updating a module that I built for my site. When I originally built the module, I didn't know much about Drupal and I gave it a version of 0.0.1. Now I'm working on a completely different version that will be using 7.x-2.x as the version. I need to run an update for the module to work. I have this function

function contacts_blocks_update_7200() {
  // Update code.
}


When I go to update.php on my site, I get an error that there are no pending updates. I've also tried contacts_blocks_update_7201. Neither is working. I do not understand how to make an update run this function. I've had a similar issue with another module and was never able to get the update function to run and ended up doing it manually.

I checked the schema_version of the module in the system table and it says 0. I'd really like to learn how to do this. How do I determine the N for hook_update_N?
Provided your project's machine name is contacts_blocks, make sure that your implemenation of hook_update_N is located in a file named contacts_blocks.install that is inside your project directory.  (Make sure you spell it exactly right contacts_blocks.insall will not work.)

The four digits should be [major version][minor version][2 digits for sequence], so the correct name in your case (branch 7.x-2.x) should be 72XX, where XX is some sequence number.

To figure out what number to use for the last two digits, run the following query:

SELECT schema_version FROM `system` WHERE name = 'contacts_blocks';


If it returns no result, then use 7200.
If it returns something below 7200, then use 7200.
If it returns a number above 7200, but below 7298, then increment with 1 and use that (e.g. if it returns 7202, use 7203).

If there is a weird value for schema_version in the systems table, and you're just experimenting (i.e. nobody else have your module, so you're not going to distribute the contacts_blocks.install file with your update to anyone), you can get a fresh start by disabling and uninstalling the module (just disabling is not enough), the reinstalling it again.

API link: function hook_update_N