wiki.techinc.nl/maintenance/sqlite/archives/patch-page_restrictions-null.sql
Máté Szabó 992da671a1 Add schema change to make page.page_restrictions column nullable
The page.page_restrictions field was used to store protection settings
for pages before MediaWiki 1.10 introduced the page_restrictions table.
update.php has since been running the updateRestrictions.php maintenance
script to migrate data from the legacy field to the new table.

In preparation for dropping this field, it is necessary to first make this
column nullable, so that we can remove code that references it during write
operations. This patch adds migrations for MySQL and SQLite to make the column
type 'tinyblob NULL'. Postgres does not seem to require a schema change, as the
field definition there is 'TEXT' rather than 'TEXT NOT NULL'.

Bug: T218446
Change-Id: I626859cdb5ab81c504a986129d21059ab088b8bd
2020-03-20 20:51:55 +01:00

37 lines
1.3 KiB
PL/PgSQL

-- (T218446) Make page.page_restrictions nullable in preparation for dropping it
BEGIN;
DROP TABLE IF EXISTS /*_*/page_tmp;
CREATE TABLE /*_*/page_tmp (
page_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
page_namespace int NOT NULL,
page_title varchar(255) binary NOT NULL,
page_restrictions tinyblob NULL,
page_is_redirect tinyint unsigned NOT NULL default 0,
page_is_new tinyint unsigned NOT NULL default 0,
page_random real unsigned NOT NULL,
page_touched binary(14) NOT NULL default '',
page_links_updated varbinary(14) NULL default NULL,
page_latest int unsigned NOT NULL,
page_len int unsigned NOT NULL,
page_content_model varbinary(32) DEFAULT NULL,
page_lang varbinary(35) DEFAULT NULL
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/page_tmp
SELECT page_id, page_namespace, page_title, page_restrictions, page_is_redirect,
page_is_new, page_random, page_touched, page_links_updated, page_latest, page_len,
page_content_model, page_lang
FROM /*_*/page;
DROP TABLE /*_*/page;
ALTER TABLE /*_*/page_tmp RENAME TO /*_*/page;
CREATE UNIQUE INDEX /*i*/name_title ON /*_*/page (page_namespace,page_title);
CREATE INDEX /*i*/page_random ON /*_*/page (page_random);
CREATE INDEX /*i*/page_len ON /*_*/page (page_len);
CREATE INDEX /*i*/page_redirect_namespace_len ON /*_*/page (page_is_redirect, page_namespace, page_len);
COMMIT;