wiki.techinc.nl/maintenance/sqlite/archives/patch-externallinks-el_index_60-drop-default.sql
Brad Jorsch aef72c5cf6 Populate externallinks.el_index_60 and drop default
Adds a maintenance script to populate the field, has that be
automatically run during update.php, and drops the no-longer-needed
default value on the column (where possible: mssql has some sort of
constraint thing going on that I have no idea how it works).

Bug: T59176
Change-Id: I971edf013a1a39466aca3b6e34c915cb24fd3aa7
2018-05-15 12:08:35 -04:00

21 lines
908 B
SQL

-- To change the default on one column, sqlite requires we copy the whole table
CREATE TABLE /*_*/externallinks_tmp (
el_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
el_from int unsigned NOT NULL default 0,
el_to blob NOT NULL,
el_index blob NOT NULL,
el_index_60 varbinary(60) NOT NULL
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/externallinks_tmp
SELECT el_id, el_from, el_to, el_index, el_index_60 FROM /*_*/externallinks;
DROP TABLE /*_*/externallinks;
ALTER TABLE /*_*/externallinks_tmp RENAME TO /*_*/externallinks;
CREATE INDEX /*i*/el_from ON /*_*/externallinks (el_from, el_to(40));
CREATE INDEX /*i*/el_to ON /*_*/externallinks (el_to(60), el_from);
CREATE INDEX /*i*/el_index ON /*_*/externallinks (el_index(60));
CREATE INDEX /*i*/el_index_60 ON /*_*/externallinks (el_index_60, el_id);
CREATE INDEX /*i*/el_from_index_60 ON /*_*/externallinks (el_from, el_index_60, el_id);