-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: sql/abstractSchemaChanges/patch-categorylinks-drop-cl_to-cl_collation.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__categorylinks AS
SELECT
  cl_from,
  cl_target_id,
  cl_sortkey,
  cl_sortkey_prefix,
  cl_timestamp,
  cl_type,
  cl_collation_id
FROM /*_*/categorylinks;

DROP TABLE /*_*/categorylinks;


CREATE TABLE /*_*/categorylinks (
  cl_from INTEGER UNSIGNED DEFAULT 0 NOT NULL,
  cl_target_id BIGINT UNSIGNED NOT NULL,
  cl_sortkey BLOB DEFAULT '' NOT NULL,
  cl_sortkey_prefix BLOB DEFAULT '' NOT NULL,
  cl_timestamp DATETIME NOT NULL,
  cl_type TEXT DEFAULT 'page' NOT NULL,
  cl_collation_id SMALLINT UNSIGNED DEFAULT 0 NOT NULL,
  PRIMARY KEY(cl_from, cl_target_id)
);

INSERT INTO /*_*/categorylinks (
  cl_from, cl_target_id, cl_sortkey,
  cl_sortkey_prefix, cl_timestamp,
  cl_type, cl_collation_id
)
SELECT
  cl_from,
  cl_target_id,
  cl_sortkey,
  cl_sortkey_prefix,
  cl_timestamp,
  cl_type,
  cl_collation_id
FROM /*_*/__temp__categorylinks;

DROP TABLE /*_*/__temp__categorylinks;

CREATE INDEX cl_sortkey_id ON /*_*/categorylinks (
  cl_target_id, cl_type, cl_sortkey,
  cl_from
);

CREATE INDEX cl_timestamp_id ON /*_*/categorylinks (cl_target_id, cl_timestamp);
