Fix SQLite patch-(page|template)links-fix-pk.sql column order
[lhc/web/wiklou.git] / maintenance / sqlite / archives / patch-rev_text_id-default.sql
1 --
2 -- Adds a default value to the rev_text_id field in the revision table.
3 -- This is to allow the Multi Content Revisions migration to happen where
4 -- rows will have to be added to the revision table with no rev_text_id.
5 --
6 -- 2018-03-12
7 --
8
9 BEGIN TRANSACTION;
10
11 DROP TABLE IF EXISTS /*_*/revision_tmp;
12
13 CREATE TABLE /*_*/revision_tmp (
14 rev_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
15 rev_page int unsigned NOT NULL,
16 rev_text_id int unsigned NOT NULL default 0,
17 rev_comment varbinary(767) NOT NULL default '',
18 rev_user int unsigned NOT NULL default 0,
19 rev_user_text varchar(255) binary NOT NULL default '',
20 rev_timestamp binary(14) NOT NULL default '',
21 rev_minor_edit tinyint unsigned NOT NULL default 0,
22 rev_deleted tinyint unsigned NOT NULL default 0,
23 rev_len int unsigned,
24 rev_parent_id int unsigned default NULL,
25 rev_sha1 varbinary(32) NOT NULL default '',
26 rev_content_model varbinary(32) DEFAULT NULL,
27 rev_content_format varbinary(64) DEFAULT NULL
28
29 ) /*$wgDBTableOptions*/ MAX_ROWS=10000000 AVG_ROW_LENGTH=1024;
30
31 INSERT OR IGNORE INTO /*_*/revision_tmp (
32 rev_id, rev_page, rev_text_id, rev_comment, rev_user, rev_user_text,
33 rev_timestamp, rev_minor_edit, rev_deleted, rev_len, rev_parent_id,
34 rev_sha1, rev_content_model, rev_content_format
35 )
36 SELECT
37 rev_id, rev_page, rev_text_id, rev_comment, rev_user, rev_user_text,
38 rev_timestamp, rev_minor_edit, rev_deleted, rev_len, rev_parent_id,
39 rev_sha1, rev_content_model, rev_content_format
40 FROM /*_*/revision;
41
42 DROP TABLE /*_*/revision;
43
44 ALTER TABLE /*_*/revision_tmp RENAME TO /*_*/revision;
45
46 CREATE INDEX /*i*/rev_page_id ON /*_*/revision (rev_page, rev_id);
47 CREATE INDEX /*i*/rev_timestamp ON /*_*/revision (rev_timestamp);
48 CREATE INDEX /*i*/page_timestamp ON /*_*/revision (rev_page,rev_timestamp);
49 CREATE INDEX /*i*/user_timestamp ON /*_*/revision (rev_user,rev_timestamp);
50 CREATE INDEX /*i*/usertext_timestamp ON /*_*/revision (rev_user_text,rev_timestamp);
51 CREATE INDEX /*i*/page_user_timestamp ON /*_*/revision (rev_page,rev_user,rev_timestamp);
52
53 COMMIT;