aboutsummaryrefslogtreecommitdiffstats
path: root/sql/sqlite/patch-templatelinks-target_id.sql
blob: ef19727ab70c256d4f9dfc6599451e591ed76b10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: sql/abstractSchemaChanges/patch-templatelinks-target_id.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__templatelinks AS
SELECT
  tl_from,
  tl_namespace,
  tl_title,
  tl_from_namespace
FROM /*_*/templatelinks;
DROP TABLE /*_*/templatelinks;


CREATE TABLE /*_*/templatelinks (
    tl_from INTEGER UNSIGNED DEFAULT 0 NOT NULL,
    tl_namespace INTEGER DEFAULT 0 NOT NULL,
    tl_title BLOB DEFAULT '' NOT NULL,
    tl_from_namespace INTEGER DEFAULT 0 NOT NULL,
    tl_target_id BIGINT UNSIGNED DEFAULT NULL,
    PRIMARY KEY(tl_from, tl_namespace, tl_title)
  );
INSERT INTO /*_*/templatelinks (
    tl_from, tl_namespace, tl_title, tl_from_namespace
  )
SELECT
  tl_from,
  tl_namespace,
  tl_title,
  tl_from_namespace
FROM
  /*_*/__temp__templatelinks;
DROP TABLE /*_*/__temp__templatelinks;

CREATE INDEX tl_namespace ON /*_*/templatelinks (tl_namespace, tl_title, tl_from);

CREATE INDEX tl_backlinks_namespace ON /*_*/templatelinks (
    tl_from_namespace, tl_namespace,
    tl_title, tl_from
  );

CREATE INDEX tl_target_id ON /*_*/templatelinks (tl_target_id, tl_from);

CREATE INDEX tl_backlinks_namespace_target_id ON /*_*/templatelinks (
    tl_from_namespace, tl_target_id,
    tl_from
  );