-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: schema/abstractSchemaChanges/patch-cu_changes-drop-cuc_private.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__cu_changes AS
SELECT
  cuc_id,
  cuc_namespace,
  cuc_title,
  cuc_actor,
  cuc_comment_id,
  cuc_minor,
  cuc_page_id,
  cuc_this_oldid,
  cuc_last_oldid,
  cuc_type,
  cuc_timestamp,
  cuc_ip,
  cuc_ip_hex,
  cuc_xff,
  cuc_xff_hex,
  cuc_agent,
  cuc_agent_id
FROM /*_*/cu_changes;

DROP TABLE /*_*/cu_changes;


CREATE TABLE /*_*/cu_changes (
  cuc_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  cuc_namespace INTEGER DEFAULT 0 NOT NULL,
  cuc_title BLOB DEFAULT '' NOT NULL,
  cuc_actor BIGINT UNSIGNED NOT NULL,
  cuc_comment_id BIGINT UNSIGNED NOT NULL,
  cuc_minor SMALLINT DEFAULT 0 NOT NULL,
  cuc_page_id INTEGER UNSIGNED DEFAULT 0 NOT NULL,
  cuc_this_oldid INTEGER UNSIGNED DEFAULT 0 NOT NULL,
  cuc_last_oldid INTEGER UNSIGNED DEFAULT 0 NOT NULL,
  cuc_type SMALLINT UNSIGNED DEFAULT 0 NOT NULL,
  cuc_timestamp BLOB NOT NULL,
  cuc_ip VARCHAR(255) DEFAULT '',
  cuc_ip_hex VARCHAR(255) DEFAULT NULL,
  cuc_xff BLOB DEFAULT '',
  cuc_xff_hex VARCHAR(255) DEFAULT NULL,
  cuc_agent BLOB DEFAULT NULL,
  cuc_agent_id BIGINT UNSIGNED DEFAULT 0 NOT NULL
);

INSERT INTO /*_*/cu_changes (
  cuc_id, cuc_namespace, cuc_title,
  cuc_actor, cuc_comment_id, cuc_minor,
  cuc_page_id, cuc_this_oldid, cuc_last_oldid,
  cuc_type, cuc_timestamp, cuc_ip,
  cuc_ip_hex, cuc_xff, cuc_xff_hex,
  cuc_agent, cuc_agent_id
)
SELECT
  cuc_id,
  cuc_namespace,
  cuc_title,
  cuc_actor,
  cuc_comment_id,
  cuc_minor,
  cuc_page_id,
  cuc_this_oldid,
  cuc_last_oldid,
  cuc_type,
  cuc_timestamp,
  cuc_ip,
  cuc_ip_hex,
  cuc_xff,
  cuc_xff_hex,
  cuc_agent,
  cuc_agent_id
FROM
  /*_*/__temp__cu_changes;

DROP TABLE /*_*/__temp__cu_changes;

CREATE INDEX cuc_ip_hex_time ON /*_*/cu_changes (cuc_ip_hex, cuc_timestamp);

CREATE INDEX cuc_xff_hex_time ON /*_*/cu_changes (cuc_xff_hex, cuc_timestamp);

CREATE INDEX cuc_timestamp ON /*_*/cu_changes (cuc_timestamp);

CREATE INDEX cuc_actor_ip_time ON /*_*/cu_changes (cuc_actor, cuc_ip, cuc_timestamp);
