When upgrading from 1.31 to 1.33 the patch-drop-ct_tag.sql patch fails due to it attempting to create duplicate unique keys in the change_tag_rc_tag_id unique index by converting all NULL to 0. MobileFrontend creates two change tags per mobile web edit and MediaWiki itself creates two change tags during an undo was a redirect.
PHP 7.2+, Aurora MySQL, Ubuntu/Debian
Table change_tag contains ct_tag field. Dropping ...General exception while running update: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? Query: ALTER TABLE `change_tag` MODIFY ct_tag_id int unsigned NOT NULL Function: Wikimedia\Rdbms\Database::sourceFile( maintenance/archives/patch-drop-ct_tag.sql ) Error: 1062 Duplicate entry '170920-0' for key 'change_tag_rc_tag_id' (****:3306)
Example data:
+-------+----------+-----------+-----------+----------------------------+-----------+-----------+ | ct_id | ct_rc_id | ct_log_id | ct_rev_id | ct_tag | ct_params | ct_tag_id | +-------+----------+-----------+-----------+----------------------------+-----------+-----------+ | 185 | 217216 | NULL | 525456 | mobile edit | NULL | NULL | | 186 | 217216 | NULL | 525456 | mobile web edit | NULL | NULL | | 656 | 242085 | NULL | 546513 | mw-changed-redirect-target | NULL | NULL | | 657 | 242085 | NULL | 546513 | mw-undo | NULL | NULL |
SHOW CREATE TABLE change_tag;
CREATE TABLE `change_tag` ( `ct_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ct_rc_id` int(11) DEFAULT NULL, `ct_log_id` int(10) unsigned DEFAULT NULL, `ct_rev_id` int(10) unsigned DEFAULT NULL, `ct_tag` varbinary(255) NOT NULL DEFAULT '', `ct_params` blob, `ct_tag_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`ct_id`), UNIQUE KEY `change_tag_rc_tag_id` (`ct_rc_id`,`ct_tag_id`), UNIQUE KEY `change_tag_log_tag_id` (`ct_log_id`,`ct_tag_id`), UNIQUE KEY `change_tag_rev_tag_id` (`ct_rev_id`,`ct_tag_id`), KEY `change_tag_tag_id` (`ct_tag`,`ct_rc_id`,`ct_rev_id`,`ct_log_id`), KEY `change_tag_tag_id_id` (`ct_tag_id`,`ct_rc_id`,`ct_rev_id`,`ct_log_id`), KEY `change_tag_rc_tag_nonuniq` (`ct_rc_id`,`ct_tag`), KEY `change_tag_log_tag_nonuniq` (`ct_log_id`,`ct_tag`), KEY `change_tag_rev_tag_nonuniq` (`ct_rev_id`,`ct_tag`) ) ENGINE=InnoDB AUTO_INCREMENT=11416 DEFAULT CHARSET=binary