Steps to replicate the issue
have a version 1.34 mediawiki sqlite database. try to upgrade to latest mediawiki LTS version 1.43
What happens?:
first upgrade to v1.35 works flawlessly.
:~/mediawiki-1.35.14$ php maintenance/update.php MediaWiki 1.35.14 Updater Your composer.lock file is up to date with current dependencies! Going to run database updates for duply Using SQLite file: '/home/dup/data.bug//duply.sqlite' Depending on the size of your database this may take a while! Abort with control-c in the next five seconds (skip this countdown with --quick) ... 0 ...have ss_active_users field in site_stats table. ...ss_active_users user count set... SNIP ...Update 'populate pp_sortkey' already logged as completed. Use --force to run it again. ...Update 'populate ip_changes' already logged as completed. Use --force to run it again. ...externallinks table indexes up to date Purging caches...done. Done in 4.8 s.
next step upgrade to v1.43 fails with
:~/mediawiki-1.43.3$ /usr/local/php-8.4.10/bin/php maintenance/update.php
*******************************************************************************
NOTE: Do not run maintenance scripts directly, use maintenance/run.php instead!
Running scripts directly has been deprecated in MediaWiki 1.40.
It may not work for some (or any) scripts in the future.
*******************************************************************************
MediaWiki 1.43.3 Updater
Your composer.lock file is up to date with current dependencies!
Going to run database updates for duply
Using SQLite file: '/home/user/data.bug//duply.sqlite'
Depending on the size of your database this may take a while!
Abort with control-c in the next five seconds (skip this countdown with --quick) ...0
Updating category collations...
Selecting next 100 pages from cl_from = 0... processing... 0 done.
0 rows processed
...done.
Modifying content_id field of table content...done.
SNIP
Converting djvu metadata...
Finished refreshing file metadata for 0 files. 0 needed to be refreshed, 0 did not need to be but were refreshed anyways, and 0 refreshes were suspicious.
...done.
Table page_restrictions contains pr_user field. Dropping...Wikimedia\Rdbms\DBQueryError from line 1198 of /home/user/mediawiki-1.43.3/includes/libs/rdbms/database/Database.php: Error 1: no such index: pr_pagetype
Function: Wikimedia\Rdbms\Database::sourceFile( /home/user/mediawiki-1.43.3/maintenance/sqlite/archives/patch-drop-page_restrictions-pr_user.sql )
Query: DROP INDEX pr_pagetype
#0 /home/user/mediawiki-1.43.3/includes/libs/rdbms/database/Database.php(1182): Wikimedia\Rdbms\Database->getQueryException('no such index: ...', 1, 'DROP INDEX pr_...', 'Wikimedia\\Rdbms...')
#1 /home/user/mediawiki-1.43.3/includes/libs/rdbms/database/Database.php(1156): Wikimedia\Rdbms\Database->getQueryExceptionAndLog('no such index: ...', 1, 'DROP INDEX pr_...', 'Wikimedia\\Rdbms...')
#2 /home/user/mediawiki-1.43.3/includes/libs/rdbms/database/Database.php(647): Wikimedia\Rdbms\Database->reportQueryError('no such index: ...', 1, 'DROP INDEX pr_...', 'Wikimedia\\Rdbms...', false)
#3 /home/user/mediawiki-1.43.3/includes/libs/rdbms/database/Database.php(2791): Wikimedia\Rdbms\Database->query(Object(Wikimedia\Rdbms\Query), 'Wikimedia\\Rdbms...')
#4 /home/user/mediawiki-1.43.3/includes/libs/rdbms/database/Database.php(2729): Wikimedia\Rdbms\Database->sourceStream(Resource id #910, NULL, NULL, 'Wikimedia\\Rdbms...', NULL)
#5 /home/user/mediawiki-1.43.3/includes/libs/rdbms/database/DBConnRef.php(127): Wikimedia\Rdbms\Database->sourceFile('/home/user/media...')
#6 /home/user/mediawiki-1.43.3/includes/libs/rdbms/database/DBConnRef.php(799): Wikimedia\Rdbms\DBConnRef->__call('sourceFile', Array)
#7 /home/user/mediawiki-1.43.3/includes/installer/DatabaseUpdater.php(797): Wikimedia\Rdbms\DBConnRef->sourceFile('/home/user/media...')
#8 /home/user/mediawiki-1.43.3/includes/installer/DatabaseUpdater.php(921): MediaWiki\Installer\DatabaseUpdater->applyPatch('/home/user/media...', false, 'Table page_rest...')
#9 /home/user/mediawiki-1.43.3/includes/installer/DatabaseUpdater.php(595): MediaWiki\Installer\DatabaseUpdater->dropField('page_restrictio...', 'pr_user', 'patch-drop-page...')
#10 /home/user/mediawiki-1.43.3/includes/installer/DatabaseUpdater.php(548): MediaWiki\Installer\DatabaseUpdater->runUpdates(Array, false)
#11 /home/user/mediawiki-1.43.3/maintenance/update.php(195): MediaWiki\Installer\DatabaseUpdater->doUpdates(Array)
#12 /home/user/mediawiki-1.43.3/maintenance/includes/MaintenanceRunner.php(703): UpdateMediaWiki->execute()
#13 /home/user/mediawiki-1.43.3/maintenance/doMaintenance.php(100): MediaWiki\Maintenance\MaintenanceRunner->run()
#14 /home/user/mediawiki-1.43.3/maintenance/update.php(308): require_once('/home/user/media...')
#15 {main}What should have happened instead?:
upgrade should run through of course. i tried with legacy LTS v1.39 as well, same issue.
Workaround:
as the error describes it is trying to drop a non existing index so i patched the offending file accordingly (see below). actually all those indexes were missing.
as the file seems to be generated from the json file in the header that probably needs to be fixed.
maintenance/sqlite/archives/patch-drop-page_restrictions-pr_user.sql
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. -- Source: maintenance/abstractSchemaChanges/patch-drop-page_restrictions-pr_user.json -- Do not modify this file directly. -- See https://www.mediawiki.org/wiki/Manual:Schema_changes DROP INDEX IF EXISTS pr_pagetype; DROP INDEX IF EXISTS pr_typelevel; DROP INDEX IF EXISTS pr_level; DROP INDEX IF EXISTS pr_cascade; ...