In trying to update a 1.28 mediawiki install (SQLite based) to 1.31, found that update.php script was failing with a SQL UNIQUE violation when trying to copy pagelinks to pagelinks_tmp. The copy is done with a simple insert command which retrieves data a simple select * to copy the data, neither specifies columns, so the columns are expected to be in the same order. Looking at the schemas of the two tables after the failed attempt revealed that the columns were in different orders. I changed the order in pagelinks to match and update.php and that patch completed, but failed on the next table getting a similar update. Updated order of columns in the associated patch file and reran update.php which completed successfully.
Files in error:
maintenance/sqlite/archives/patch-pagelinks-fix-pk.sql
maintenance/sqlite/archives/patch-imagelinks-fix-pk.sql
I noticed on other threads that many table's schemas where getting updates. It might be a good idea to check on similar patches to verify that their order is correct. I expect that some table data sets could end up NOT triggering the issue on copy (ie: the data doesn't violate the UNIQUE constraints).