Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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'));
}
Comment | File | Size | Author |
---|---|---|---|
#3 | 2065213-file_entity-primary-3.patch | 691 bytes | hefox |
Comments
Comment #1
Dave ReidThe 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?
Comment #2
hefox CreditAttribution: hefox commentedpatch to be ported?
#190027: db_change_field on a serial column in the primary key
Comment #3
hefox CreditAttribution: hefox commentedComment #4
Dave ReidGrr, 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.
Comment #5
Dave ReidTested and committed #3. http://drupalcode.org/project/file_entity.git/commit/6a33a8a
Comment #6
kaidjohnson CreditAttribution: kaidjohnson commented#3/#5 did the trick here. Thanks!