always get update messages to update the module, but get then this error message:
The following updates returned messages
entity_translation module
Update #7006

Failed: DatabaseSchemaObjectExistsException: Das Feld entity_translation.revision_id konnte nicht hinzugefügt werden: Das Feld existiert bereits. in DatabaseSchema_mysql->addField() (Zeile 328 + includes/database/mysql/schema.inc).

CommentFileSizeAuthor
#10 update_from_before-2425825-10.patch1.12 KBjamesrward

Comments

caw67’s picture

always in the dev version.

entity_translation module

7006 - Add revision schema for entity translation metadata.
7007 - Disable revision support on existing installations.

plach’s picture

Status: Active » Postponed (maintainer needs more info)

Please, see https://www.drupal.org/project/entity_translation#bugfixing

(and I don't understand german, btw :)

bdupls’s picture

I too get an error message, the site seems to work fine, no errors, but when I run update.php I get this error.

The following updates returned messages

entity_translation module

Update #7006
Failed: DatabaseSchemaObjectExistsException: Cannot add field entity_translation.revision_id: field already exists. in DatabaseSchema_mysql->addField() (line 328 of /home/xxx/public_html/includes/database/mysql/schema.inc).

dblais’s picture

Same problem, same message. I think the update did not finish correctly. Field was created but the update is not marked as complete...

giorgosk’s picture

Title: update » update from before beta4 fails
Status: Postponed (maintainer needs more info) » Active

updated with drush
drush up entity_translation and ended up with this

 Entity_translation  7006  Add revision schema for entity translation metadata.  
 Entity_translation  7007  Disable revision support on existing installations.
Do you wish to run all pending updates? (y/n): y
Cannot add field entity_translation.revision_id: field already exists.

because the instructions to migrate to the new beta4 from the release notes https://www.drupal.org/node/2412615 are not that helpful (i.e. second paragraph about manual migration)

I had to run both from phpmyadmin

ALTER TABLE `entity_translation` DROP `revision_id`;
DROP TABLE `entity_translation_revision`;

because I was getting more errors after droping revision_id

-sh-4.1$ drush updb
 Entity_translation  7006  Add revision schema for entity translation metadata.  
 Entity_translation  7007  Disable revision support on existing installations.
Do you wish to run all pending updates? (y/n): y
Table entity_translation_revision already exists.                                                                            [error]
Performed update: entity_translation_update_7006                                                                             [ok]
'all' cache was cleared.                                                                                                     [success]
Finished performing updates.

after that the updb run smoothly and site did not seem to have any problem after the update

please use at your own risk (and do backup of the site first)

plach’s picture

Title: update from before beta4 fails » Update from before beta4 fails
Assigned: caw67 » Unassigned
Status: Active » Postponed (maintainer needs more info)

Ok, so this seems a documentation issue. Any suggestion on how to make release notes more clear about what to do?

The intended process should be:

  1. Apply updates as usual
  2. If you don't wish to enable revision support stop here
  3. If you do, manually alter your data, altering schema is not necessary, although some optimizations are possible
giorgosk’s picture

Status: Postponed (maintainer needs more info) » Active

@plach

I never intended to make revision available (I did not know it existed)
could I have enabled it on a version before beta4 ?
because surely I only tried to do an update from this version

-----------------
; Information added by Drupal.org packaging script on 2014-09-30
version = "7.x-1.0-beta3+14-dev"
core = "7.x"
project = "entity_translation"
datestamp = "1412097246"
---------------
why did it create this problem problem since 2. applied to my case ?
is it surely a documentation problem ?

plach’s picture

Well, updates are supported only between beta versions, if you installed a -dev and then updated to beta4 it's actually possible that the update process was somehow broken. To be sure ideally you should grab a backup of your site with beta3 and update directly to beta4. I realize this may be difficult but this would ensure the test is fair.

jurgenhaas’s picture

I think the format of the update script could be easily improved so that it works in any case - although I don't understand how a scenario could happen where a field or table already exists and should be generated by an update script again.

However, here is how I always do that in my modules:

function entity_translation_update_7006() {
  $schema = entity_translation_schema();
  
  // Create revision id column.
  if (!db_field_exists('entity_translation', 'revision_id')) {
    // If we have existing data we cannot enforce this to be NOT NULL.
    $schema['entity_translation']['fields']['revision_id']['not null'] = FALSE;
    db_add_field('entity_translation', 'revision_id', $schema['entity_translation']['fields']['revision_id']);
  }

  // Create the entity translation revision schema.
  if (!db_table_exists('entity_translation_revision')) {
    db_create_table('entity_translation_revision', $schema['entity_translation_revision']);
  }
}

This is much shorter, works in all cases and avoids redundant code.

jamesrward’s picture

StatusFileSize
new1.12 KB

Here's a patch with the suggestions from #9. Just ran into this issue trying to upgrade an existing site to beta4 via wetkit 1.10. As described above updatedb fails with:

entity_translation module
Update #7006
Failed: DatabaseSchemaObjectExistsException: Table entity_translation_revision already exists. in DatabaseSchema->createTable()
denix’s picture

Status: Active » Patch (to be ported)

I confirm the patch works well.

denix’s picture

Status: Patch (to be ported) » Needs review
vegardjo’s picture

Status: Needs review » Reviewed & tested by the community

Works just fine here as well

  • plach committed d231b65 on 7.x-1.x authored by jamesrward
    Issue #2425825 by jamesrward: Update from before beta4 fails
    
plach’s picture

Status: Reviewed & tested by the community » Fixed

This is much shorter, works in all cases and avoids redundant code.

The only problem with that suggestion is it's not 100% reliable, as it produces an unpredictable update flow, I strongly recommend not to follow it.

I just committed #10 that looks more or less correct as a stop-gap fix, although it would be better to figure out why the schema was already there before running the update function. Maybe the update was not completing successfully and it was being run twice? I guess we'll never know.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.