-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: schema/abstractSchemaChanges/patch-cu_log_event-drop-cule_ip.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__cu_log_event AS
SELECT
  cule_id,
  cule_log_id,
  cule_actor,
  cule_timestamp,
  cule_ip_hex,
  cule_xff,
  cule_xff_hex,
  cule_agent_id
FROM /*_*/cu_log_event;

DROP TABLE /*_*/cu_log_event;


CREATE TABLE /*_*/cu_log_event (
  cule_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  cule_log_id INTEGER UNSIGNED DEFAULT 0 NOT NULL,
  cule_actor BIGINT UNSIGNED NOT NULL,
  cule_timestamp BLOB NOT NULL,
  cule_ip_hex VARCHAR(255) DEFAULT NULL,
  cule_xff BLOB DEFAULT '',
  cule_xff_hex VARCHAR(255) DEFAULT NULL,
  cule_agent_id BIGINT UNSIGNED DEFAULT 0 NOT NULL
);

INSERT INTO /*_*/cu_log_event (
  cule_id, cule_log_id, cule_actor,
  cule_timestamp, cule_ip_hex, cule_xff,
  cule_xff_hex, cule_agent_id
)
SELECT
  cule_id,
  cule_log_id,
  cule_actor,
  cule_timestamp,
  cule_ip_hex,
  cule_xff,
  cule_xff_hex,
  cule_agent_id
FROM /*_*/__temp__cu_log_event;

DROP TABLE /*_*/__temp__cu_log_event;

CREATE INDEX cule_ip_hex_time ON /*_*/cu_log_event (cule_ip_hex, cule_timestamp);

CREATE INDEX cule_xff_hex_time ON /*_*/cu_log_event (cule_xff_hex, cule_timestamp);

CREATE INDEX cule_timestamp ON /*_*/cu_log_event (cule_timestamp);

CREATE INDEX cule_actor_ip_hex_time ON /*_*/cu_log_event (
  cule_actor, cule_ip_hex, cule_timestamp
);
