When I first developed this module internally (not on Druple.com) the module_schema function created a table with the same name of the module (it was the only table, so it made sense. Short sighted.).

But I now need a 2nd table, so the first table should have a more sensible name. There is also a requirement for an additional field in the original table.

 function afd_pce_update_dependencies(){
   // update_7201 needs to run after update_7200.
   $dependencies['mymodule_field_mappings'][7201] = array(
     'mymodule_field_mappings' => 7200,

   return $dependencies;

 function mymodule_update_7200(){
      db_rename_table('mymodule', 'mymodule_field_mappings');

 function mymodule_update_7201(){
   $spec = array(
     'type' => 'varchar',
     'description' => "The fieldset that this mapping belongs to",
     'length' => 15,
     'not null' => FALSE,

When I run update.php I get the error

Update #7201
Failed: DatabaseSchemaObjectDoesNotExistException:
Cannot add field <em class="placeholder">fieldset_type</em>.
<em class="placeholder">mymodule_field_mappings</em>: table doesn't exist. 
in DatabaseSchema_mysql->addField() (line 325 of

1 Answer 1


I think your mixing up table names and module names in hook_update_dependencies().

First of all, you don't need hook_update_dependencies() to declare dependencies inside your own module. The updates will always be run sequentially, so that mymodule_update_7200() will always run before mymodule_update_7201().

Then, if you want to use hook_update_dependencies(), you would use it to declare inter-module depenencies like this:

function mymodule_update_dependencies(){
  $dependencies['mymodule'][7201] = array(
    'other_module' => 7203,
  return $dependencies;

Now to your error. Can you check in the system table record for your module what the current schema version is? From the code and the error message I would suppose, that the database is already at schema 7200 (at least officially) but that somehow the renaming has not been done. Is it maybe possible that you have altered the database manually?

Edit: You are mixing up the arguments to db_add_field. It must be db_add_field('mymodule_field_mappings', 'fieldset_type', $spec);

  • I'm manually rolling back the changes before retesting. Named the table back to the old name and in the system table set the schema_version = 0
    – KevinManx
    Feb 3, 2014 at 16:49
  • @KevinManx Wrong arguments for db_add_field. See updated answer.
    – berliner
    Feb 3, 2014 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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