Am trying to see if the dev version fixes issues introduces with the latest updates to media and file_entity
I get this error message on update, from both drush and update.php

Update #7215
Failed: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key: ALTER TABLE {file_metadata} DROP PRIMARY KEY; Array ( ) in db_drop_primary_key() (line 2901 of /includes/database/database.inc).

The structure of the table:

mysql> DESC file_metadata;
+-------+------------------+------+-----+---------+----------------+
| Field | Type             | Null | Key | Default | Extra          |
+-------+------------------+------+-----+---------+----------------+
| fid   | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| name  | varchar(255)     | NO   | PRI | NULL    |                |
| value | longblob         | YES  |     | NULL    |                |
+-------+------------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)

The update in question:

/**
 * Fix the {file_metadata}.fid schema.
 */
function file_entity_update_7215() {
  db_drop_primary_key('file_metadata');
  db_change_field('file_metadata', 'fid', 'fid', array(
    'description' => 'The {file_managed}.fid of the metadata.',
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_primary_key('file_metadata', array('fid', 'name'));
}

CommentFileSizeAuthor
#3 2065213-file_entity-primary-3.patch691 byteshefox
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Status: Active » Patch (to be ported)

The update is what's fixing that error. The update should continue to work and fix the issue. What is the schema *after* the table updates?

hefox’s picture

hefox’s picture

Status: Patch (to be ported) » Needs review
FileSize
691 bytes
Dave Reid’s picture

Grr, I should have clicked postponed (maintainer needs more info). Confirmed this is what's needed. Very strange and this definitely needs to be documented somewhere.

Dave Reid’s picture

Status: Needs review » Fixed
kaidjohnson’s picture

#3/#5 did the trick here. Thanks!

Status: Fixed » Closed (fixed)

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