2 -- Create the new redirect table.
3 -- For each redirect, this table contains exactly one row defining its target
5 CREATE TABLE /*$wgDBprefix*/redirect (
6 -- Key to the page_id of the redirect page
7 rd_from
int unsigned
NOT NULL default '0',
9 -- Key to page_namespace/page_title of the target page.
10 -- The target page may or may not exist, and due to renames
11 -- and deletions may refer to different page records as time
13 rd_namespace
int NOT NULL default '0',
14 rd_title
varchar(255) binary NOT NULL default '',
16 PRIMARY KEY rd_from (rd_from
),
17 KEY rd_ns_title (rd_namespace
,rd_title
,rd_from
)
18 ) /*$wgDBTableOptions*/;
20 -- Import existing redirects
21 -- Using ignore because some of the redirect pages contain more than one link
23 INTO /*$wgDBprefix*/redirect (rd_from
,rd_namespace
,rd_title
)
24 SELECT pl_from
,pl_namespace
,pl_title
25 FROM /*$wgDBprefix*/pagelinks
, /*$wgDBprefix*/page
26 WHERE pl_from
=page_id
AND page_is_redirect
=1;