Thread:Project:Support desk/Database returned error "1091: Can't DROP 'PRIMARY'; check that column/key exists (localhost)"

i posted this also on manual_talk:upgrading, but haven't got a response yet.

getting this error trying to upgrade from 1.15.3 to 1.19.0. i run about 70 wiki instances, all are at 1.15.3. i'm scripting the upgrade to 1.19.0 essentially just running a loop for each wiki. i ran into issues where about 25 of the wiki database users didn't have INDEX granted [our older wikis]. i fixed that, reverted to my pre-upgrade backup, and now for each wiki that didn't have INDEX [but does now] i'm getting this error. for all the newer wikis that DID have index, they are upgrading fine.

my full error is: Adding index ls_field_val to table log_search... A database query syntax error has occurred. The last attempted database query was: "ALTER TABLE `log_search` DROP PRIMARY KEY,  ADD UNIQUE INDEX ls_field_val (ls_field,ls_value,ls_log_id) " from within function "DatabaseBase::sourceFile( /path/to/wiki/maintenance/archives/patch-log_search-rename-index.sql )". Database returned error "1091: Can't DROP 'PRIMARY'; check that column/key exists (localhost)"

more confusingly is that on all wikis [those that upgrade properly and those that do not] the log_search table doesn't exist pre upgrade.

pre upgrade: mysql> use WIKI_THAT_DOESN'T_UPGRADE_PROPERLY; Database changed mysql> desc log_search; ERROR 1146 (42S02): Table 'WIKI_THAT_DOESN'T_UPGRADE_PROPERLY.log_search' doesn't exist mysql> use WIKI_THAT_WORKS; Database changed mysql> desc log_search; ERROR 1146 (42S02): Table 'WIKI_THAT_WORKS.log_search' doesn't exist

post upgrade: mysql> use WIKI_THAT_DOESN'T_UPGRADE_PROPERLY; Database changed mysql> desc log_search; +---+--+--+-+-+---+ | Field    | Type             | Null | Key | Default | Extra | +---+--+--+-+-+---+ | ls_field | varbinary(32)    | NO   |     | NULL    |       | | ls_value | varchar(255)     | NO   |     | NULL    |       | | ls_log_id | int(10) unsigned | NO  |     | 0       |       | +---+--+--+-+-+---+ 3 rows in set (0.00 sec)

mysql> use WIKI_THAT_WORKS; Database changed mysql> desc log_search; +---+--+--+-+-+---+ | Field    | Type             | Null | Key | Default | Extra | +---+--+--+-+-+---+ | ls_field | varbinary(32)    | NO   | PRI | NULL    |       | | ls_value | varbinary(255)   | NO   | PRI | NULL    |       | | ls_log_id | int(10) unsigned | NO  | PRI | 0       |       | +---+--+--+-+-+---+ 3 rows in set (0.45 sec)

more info:

checking /path/to/wiki/maintenance/archives/patch-log_search-rename-index.sql

-- Rename the primary unique index from PRIMARY to ls_field_val -- This is for MySQL only and is necessary only for databases which were updated -- between MW 1.16 development revisions r50567 and r51465. ALTER TABLE /*_*/log_search DROP PRIMARY KEY, ADD UNIQUE INDEX ls_field_val (ls_field,ls_value,ls_log_id);

so i don't get why it's even doing this rev, as all my instances are 1.15.3. i'm jumping over 1.16. ..