What do i do if update.php encounters errors?

Events happening in the community are now at Drupal community events on www.drupal.org.
aprice42's picture

Hello,

I just ran a few updates and encountered (for the first time) some errors when running update.php. The instructions on the page say that if you encounter errors you may need to update them manually. So two questions:

  1. It says MAY need to update manually, so how do I know if I really need to do anything?

  2. If I need to manually update them how do I do that? can I just copy and paste the failed query into phpMyAdmin (I am guessing no :)

Luckily I backed up my database, so i can revert back, but I do need to update these modules, can anyone offer me some advice?

Below is the output from update.php

Thanks,
Andy

image module
Update #6100

    * ALTER TABLE {image} CHANGE nid nid INT unsigned NOT NULL DEFAULT 0
    * ALTER TABLE {image} CHANGE fid fid INT unsigned NOT NULL DEFAULT 0
    * Failed: ALTER TABLE {image} DROP PRIMARY KEY
    * ALTER TABLE {image} ADD PRIMARY KEY (nid, image_size)
    * Failed: ALTER TABLE {image} DROP INDEX image_fid
    * ALTER TABLE {image} ADD INDEX fid (fid)

image_attach module
Update #6100

    * ALTER TABLE {image_attach} CHANGE nid nid INT unsigned NOT NULL DEFAULT 0
    * ALTER TABLE {image_attach} CHANGE iid iid INT unsigned NOT NULL DEFAULT 0
    * Failed: ALTER TABLE {image_attach} DROP PRIMARY KEY
    * ALTER TABLE {image_attach} ADD PRIMARY KEY (nid)
    * Failed: ALTER TABLE {image_attach} DROP INDEX iid
    * ALTER TABLE {image_attach} ADD INDEX iid (iid)

Comments

update.php errors

deatech's picture

The errors you show do not appear to be a problem. It is fairly common for there to be errors during updates where the query drops keys, columns, indexes and some other elements, this usually occurs if your database does not already have them so they cannot be dropped. It is necessary to drop them and recreate them as the old definition may no longer be correct and/or they need to create them but can't be certain that some people don't already have them. It is fairly common that people who were not using the development version may never have even had these database elements defined (hence the error). The thing to watch out for are when there are errors on creating new elements such as when these indexes and keys are added back in.

FWIW.

I agree, but in general

drm's picture

. . . in general, if I saw such errors, I would probably go into the table definition in phpmyadmin and confirm that those keys and indexes were not there. If they were, I would drop them manually.

Not needed most of the time

deatech's picture

Actually, you don't want to do that, in most cases when they drop the keys and indexes (such as the one which started this thread), they are immediately recreated, so if you drop them manually, you are actually dropping the new ones, not the old ones. If the drop fails but it is immediately followed by a create for a new key, index, etc. of the same name and the create succeeds (no error), then there is no problem since the create would fail if the drop failed and there was still an existing key or index.

Thank you

aprice42's picture

Thank you both this is very helpful...

:) Andy

Portland (Oregon)

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: