Hello, after trying to apply the latest update for this module I get the following error

image module
Update #7002

Failed: DatabaseSchemaObjectExistsException: Cannot add field field_data_field_afbeelding_extra.field_afbeelding_extra_width: field already exists. in DatabaseSchema_mysql->addField() (line 323 of /home/vanderbas2/domains/ic3d.nl/public_html/3mw/includes/database/mysql/schema.inc).

What should I do to fix this.

Comments

stevenwscott’s picture

Ditto. It appears the field now exists, so how can I mark the update completed?

Rodney Strong’s picture

Mine's a little different, but still the same type of issue:
Failed: DatabaseSchemaObjectExistsException: Cannot add field field_data_field_image.field_image_width: field already exists. in DatabaseSchema_mysql

Tried this on a brand new D7 site and a site that's 2 years old. Tried updating the db through the web interface and through drush, both resulted in the same error.

vishalkhialani’s picture

I have this same error. Did you guys manage to fix this ?

cheers,
Vishal

gagarine’s picture

Priority: Major » Normal

I arrive if you add an image before playing the update (it's why you should put your server in maintenance mode). To solve it I manually delete the new field in the table and replay the update.

I change in normal as if you follow good practice nothing break

vishalkhialani’s picture

@gagarine : how do we del it ?

Pls advice so that we can get rid of this issue.

You are right I had forgotten to put it in maintenance mode.

Cheers,
Vishal

vishalkhialani’s picture

vishalkhialani’s picture

vishalkhialani’s picture

sorry , double entry

Levdbas’s picture

ok folks,

The way to solve this issue is the following.

1. log in into your database backend like phpmyadmin
2. select your database
3. select all the field tables which holds images.
4. delete the columns field_yourname_width & field_yournome_height
5. do this with every table with images and also the revisions
6. run update again in maintainence mode. If it's not working you're overlooking one of the fields.

This solved my issue, and next time, always put your site in maintainence mode.

stevenwscott’s picture

Thanks Levdbas, worked perfectly.

greysun’s picture

I did not put my site into maintenance mode, but the "fix" does not work for me at all!

vishalkhialani’s picture

yes !! all done. will always rem the maintenance thingggy from now on

joachim’s picture

Project: Image » Drupal core
Version: 7.x-1.x-dev » 7.x-dev

Moving to core.

davidbarratt’s picture

ok, this is the error I was receiving:

Failed: DatabaseSchemaObjectDoesNotExistException: Cannot add field <em class="placeholder">field_data_field_image</em>.<em class="placeholder">field_image_width</em>: table doesn't exist. in DatabaseSchema_mysql->addField() (line 320 of /Users/david/Sites/thechurch/includes/database/mysql/schema.inc).

What I discovered, was that Drupal thought that I was using an failed called "image" when the tables for that field do not exist. I am not sure why they didn't exist, but I obviously wasn't using the field since the tables themselves were not there.

and this is how I fixed it NOTE: only do this if you are receiving an error like above ("table doesn't exist")

  1. log in into your database backend like phpmyadmin
  2. select your database
  3. Go to the table field_config
  4. Delete the row where field_name = field_image (or whatever the name of the field is that is missing the table)
  5. Go to the table field_config_instance
  6. Delete the row where field_name = field_image (or whatever the name of the field is that is missing the table)
  7. Run the DB update again at /update.php

this fixed my problem, and I hope it fixes yours.

thanks!
david barratt

JulienThomas’s picture

Hello.

I can confirm this fix. The trick was to not forget the revision tables ...

For example, consider you have already set an image in a field like field_image_image.
You must perform the following sql queries. Note that the maintenance mode is not mandatory yet strongly advised :)

The error occured as the fields *_height and *_width already existed.

/* always */
ALTER TABLE `field_data_field_image` DROP COLUMN `field_image_width`,
 DROP COLUMN `field_image_height`;
 ALTER TABLE `field_revision_field_image` DROP COLUMN `field_image_width`,
 DROP COLUMN `field_image_height`;
/* for each created image field */
ALTER TABLE `field_data_field_image_image` DROP COLUMN `field_image_image_height`,
 DROP COLUMN `field_image_image_width`;
ALTER TABLE `field_revision_field_image_image` DROP COLUMN `field_image_image_width`,
 DROP COLUMN `field_image_image_height`;

Cheers.

kyriakos1977’s picture

Thanks Levdbas, worked perfectly.

robertcfi’s picture

Followed #9 and worked perfectly. Sucked trying to find all the fields but it does work once you suck it up and delete all of them.

MickC’s picture

Fix worked - not only that but it recreatd the data.

I had data in these fields and was concerned it would get lost so I renamed the fields instead of deleting.
After running update it created the new fields with exactly the same wight and height data as my renamed fields.
I'm assuming therefore it is reading this metadata from the image files themselves, and it may well be safe to delete the fields even if you have data in them.

siteogra’s picture

http://drupal.org/node/1348410

in /modules/image/image.install 270 line

$spec['description'] = 'The width of the image in pixels.';
// db_add_field($table, $field_name . '_width', $spec);
if (!db_field_exists($table, $field_name . '_width')){
db_add_field($table, $field_name . '_width', $spec);
}

$spec['description'] = 'The height of the image in pixels.';
// db_add_field($table, $field_name . '_height', $spec);
if (!db_field_exists($table, $field_name . '_height')){
db_add_field($table, $field_name . '_height', $spec);
}

etibmw’s picture

Hi
Iused #9 thanks Levdbas
solved my issue

Magdiel Veliz’s picture

Thanks Levdbas
really Works for me....

patoshi’s picture

having same issue as of feb 23. using latest dev... is there a way to solve this issue without having to delete the columns manually?

patoshi’s picture

Here's a solution without having to go into your database:

open up modules/image/image.install

Delete the following:

Line 271 db_add_field($table, $field_name . '_width', $spec);

Line 274 db_add_field($table, $field_name . '_height', $spec);

This will bypass the column creation error.

drush updb .... and win!

samhaini’s picture

thanks , it worked very well for me...

drupov’s picture

For me it worked too. Thanks!

What I did was to comment those two lines rather than delete them and update the db.

After the update I uncommented them and still got no errors.

patoshi’s picture

having same issues with 7.14 upgrade.. apply my same fix. but there really should be a conditional to check if the column exists or not...

patoshi’s picture

Added to the image.install to check if columns exists or not:

284   if (!db_field_exists($table, $field_name . '_width')) {                                                                                                                                                                                                                   
285     db_add_field($table, $field_name . '_width', $spec);
286   }                                                     
287                                                         
288   $spec['description'] = 'The height of the image in pixels.';
289                                                         
290   if (!db_field_exists($table, $field_name . '_height')) {
291     db_add_field($table, $field_name . '_height', $spec);
292   }                                                     

This should resolve most issues as doing the other way might cause problems since we're just completely taking out the column creation completely. =)

simon fraser’s picture

thank you for that! and indeed for all the valuable help with this
(simply commenting those two lines out works for me)
still puzzled why this issue with one site (in core drupal-7.14) should affect one site and yet not others, but seeing no 'Failed' error message at last is perfectly good enough for me!

nedim.hadzimahmutovic’s picture

#19 thanks, worked for me.

webchick’s picture

Would someone be able to formulate the solutions that are working here into a patch, so we could fix it for everyone?

fraxinus’s picture

Thanks very much, Levdbas. Your method (#9) has now worked for me. I have cleaned out the field tables as you suggested, updated to Drupal 7.16 and all is now sweet again.

Jeroen94’s picture

I get the following error over and over again when I try to update the database.

dblog module
Update #7002
Failed: DatabaseSchemaObjectExistsException: Cannot add index severity to table watchdog: index already exists. in DatabaseSchema_mysql->addIndex() (line 437 of C:\wamp\www\MYSITE\includes\database\mysql\schema.inc).

How can I fix this? Please help!

Aptalops’s picture

Issue summary: View changes

Thanks all #23 solved it for me.

Vj’s picture

#19 works fine. Tested by upgrading drupal 7.14 to 7.31