Page MenuHomePhabricator

Postgres update.php missing ipb_sitewide and boolean default type error
Open, Needs TriagePublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • $wgDBtype = "postgres"
  • Upgrading from a previous version of Mediawiki to 1.35.5
  • Run php maintenance/update.php
  • Missing ipb_sitewide, run php sql.php maintenance/patch-ipb_sitewide.sql

What happens?:
Running update.php does not run patch-ipb_sitewide.sql, update.php reports missing columb ipb_sitewide
When manually running php sql.php patch-ipb_sitewide.sql, error is ERROR: column "ipb_sitewide" is of type boolean but default expression is of type integer

What should have happened instead?
update.php should run all patch scripts in postgres equivalent language

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:
Mediawiki 1.35.5
Postgres 10.6
PHP 7.4.27

Postgres Table before upgrade:

                                                             Table "mediawiki.ipblocks"
        Column        |           Type           | Collation | Nullable |                 Default                  | Storage  | Stats target | Description
----------------------+--------------------------+-----------+----------+------------------------------------------+----------+--------------+-------------
 ipb_id               | integer                  |           | not null | nextval('ipblocks_ipb_id_seq'::regclass) | plain    |              |
 ipb_address          | text                     |           |          |                                          | extended |              |
 ipb_user             | integer                  |           |          |                                          | plain    |              |
 ipb_by               | integer                  |           | not null | 0                                        | plain    |              |
 ipb_by_text          | text                     |           | not null | ''::text                                 | extended |              |
 ipb_reason           | text                     |           | not null | ''::text                                 | extended |              |
 ipb_timestamp        | timestamp with time zone |           | not null |                                          | plain    |              |
 ipb_auto             | smallint                 |           | not null | 0                                        | plain    |              |
 ipb_anon_only        | smallint                 |           | not null | 0                                        | plain    |              |
 ipb_create_account   | smallint                 |           | not null | 1                                        | plain    |              |
 ipb_enable_autoblock | smallint                 |           | not null | 1                                        | plain    |              |
 ipb_expiry           | timestamp with time zone |           | not null |                                          | plain    |              |
 ipb_range_start      | text                     |           |          |                                          | extended |              |
 ipb_range_end        | text                     |           |          |                                          | extended |              |
 ipb_deleted          | smallint                 |           | not null | 0                                        | plain    |              |
 ipb_block_email      | smallint                 |           | not null | 0                                        | plain    |              |
 ipb_allow_usertalk   | smallint                 |           | not null | 0                                        | plain    |              |
 ipb_parent_block_id  | integer                  |           |          |                                          | plain    |              |
 ipb_reason_id        | integer                  |           | not null | 0                                        | plain    |              |
 ipb_by_actor         | integer                  |           | not null | 0                                        | plain    |              |
Indexes:
    "ipblocks_pkey" PRIMARY KEY, btree (ipb_id)
    "ipb_address_unique" UNIQUE, btree (ipb_address, ipb_user, ipb_auto, ipb_anon_only)
    "ipb_parent_block_id" btree (ipb_parent_block_id)
    "ipb_range" btree (ipb_range_start, ipb_range_end)
    "ipb_user" btree (ipb_user)
Foreign-key constraints:
    "ipblocks_ipb_by_fkey" FOREIGN KEY (ipb_by) REFERENCES mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
    "ipblocks_ipb_parent_block_id_fkey" FOREIGN KEY (ipb_parent_block_id) REFERENCES ipblocks(ipb_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED
    "ipblocks_ipb_user_fkey" FOREIGN KEY (ipb_user) REFERENCES mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED
Referenced by:
    TABLE "ipblocks" CONSTRAINT "ipblocks_ipb_parent_block_id_fkey" FOREIGN KEY (ipb_parent_block_id) REFERENCES ipblocks(ipb_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED

Event Timeline

Umherirrender subscribed.

The database column is part of the update to MediaWiki 1.32, added by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/440871

			[ 'addPgField', 'ipblocks', 'ipb_sitewide', 'SMALLINT NOT NULL DEFAULT 1' ],

The patch running with php sql.php maintenance/archives/patch-ipb_sitewide.sql is a mysql/sqlite patch and not working for postgres. There is no explict patch for postgres, it is part of the updater code.

From which version before MediaWiki 1.35 your database schema is? But if it starts at 1.34, the update should add the field, if it was missing from an update before.

This is coming from MW 1.27, I also tried from MW 1.31.

If the patch is coming from the updater code, any reason why it would not run that patch first before complaining that the column does not exist?