I'm updating my site to drupal 7. I tried to upgrade biblio from 6.x-1.15 to 7.x-1.x-dev, and received the following error after running update.php:

The following updates returned messages
biblio module
Update #7000

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 {biblio_contributor_data} DROP PRIMARY KEY; Array ( ) in db_drop_primary_key() (line 2772 of /srv/www/drupal/includes/database/database.inc).

Comments

rjerome’s picture

Status: Active » Fixed

Actually, I just fixed that last night, so the current -dev release (dated Apr. 29) should work for you.

elopio’s picture

Status: Fixed » Closed (fixed)

Great!
The update finished now :)

*hug*

drupalycious’s picture

Status: Closed (fixed) » Active

I upgraded from rc5 to the latest dev and received the following message:

The following updates returned messages

biblio module

Update #7020
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 {biblio_contributor_data} DROP PRIMARY KEY; Array ( ) in db_drop_primary_key() (line 2901 of /drupalroot/includes/database/database.inc).
rjerome’s picture

which database engine are you using (MySQL, PostgreSQL)?

e5sego’s picture

I used the -dev version and it is still causing same error as in #3. There seems some wrong syntax here:

function biblio_update_7020() {
  db_drop_primary_key('biblio_contributor_data');
  db_add_primary_key('biblio_contributor_data', array('cid'));
}

Workaround

1. Manually fix the table:

ALTER TABLE `biblio_contributor_data` DROP PRIMARY KEY ,
ADD PRIMARY KEY ( `cid` ) ;

2. Edit biblio.install:

function biblio_update_7020() {
  /* just do nothing here */
}

3. Run update.php script

rjerome’s picture

The reason I asked about the Database engine is that the "work around" code that you propose

ALTER TABLE `biblio_contributor_data` DROP PRIMARY KEY ,
ADD PRIMARY KEY ( `cid` ) ;

Is exactly what I used to have in that function and it too was causing the same issue with some DB's so I'd like to know which DB's prefer which code.

jippie1948’s picture

Perhaps I found the problem: I looked into my database for the cid values and they are not unique. Hence never they can become a primary key...

Best wishes,

JP

Edit:
1. I looked into the wrong table... :( So there is no problem with unique cid values.
2. When I imported the database into a different database replacing a clean D7 install, the problem mysteriously disappeared. :)

kari.nies’s picture

I just upgraded from 7.x-1.0-rc4 to rc7 and got the same error message.

rjerome’s picture

Status: Active » Fixed

should be fixed in rc7

Status: Fixed » Closed (fixed)

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