-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: sql/abstractSchemaChanges/patch-pagelinks-drop-pl_title.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__pagelinks AS
SELECT
  pl_from,
  pl_from_namespace,
  pl_target_id
FROM /*_*/pagelinks;

DROP TABLE /*_*/pagelinks;


CREATE TABLE /*_*/pagelinks (
  pl_from INTEGER UNSIGNED DEFAULT 0 NOT NULL,
  pl_target_id BIGINT UNSIGNED NOT NULL,
  pl_from_namespace INTEGER DEFAULT 0 NOT NULL,
  PRIMARY KEY(pl_from, pl_target_id)
);

INSERT INTO /*_*/pagelinks (
  pl_from, pl_from_namespace, pl_target_id
)
SELECT
  pl_from,
  pl_from_namespace,
  pl_target_id
FROM
  /*_*/__temp__pagelinks;

DROP TABLE /*_*/__temp__pagelinks;

CREATE INDEX pl_target_id ON /*_*/pagelinks (pl_target_id, pl_from);

CREATE INDEX pl_backlinks_namespace_target_id ON /*_*/pagelinks (
  pl_from_namespace, pl_target_id,
  pl_from
);
