-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: schema/abstractSchemaChanges/patch-cu_private_event-modify-cupe_actor-nullable.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__cu_private_event AS
SELECT
  cupe_id,
  cupe_namespace,
  cupe_title,
  cupe_actor,
  cupe_log_type,
  cupe_log_action,
  cupe_params,
  cupe_comment_id,
  cupe_page,
  cupe_timestamp,
  cupe_ip,
  cupe_ip_hex,
  cupe_xff,
  cupe_xff_hex,
  cupe_agent,
  cupe_private
FROM /*_*/cu_private_event;
DROP TABLE /*_*/cu_private_event;


CREATE TABLE /*_*/cu_private_event (
    cupe_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    cupe_namespace INTEGER DEFAULT 0 NOT NULL,
    cupe_title BLOB DEFAULT '' NOT NULL,
    cupe_actor BIGINT UNSIGNED DEFAULT 0,
    cupe_log_type BLOB DEFAULT '' NOT NULL,
    cupe_log_action BLOB DEFAULT '' NOT NULL,
    cupe_params BLOB NOT NULL,
    cupe_comment_id BIGINT UNSIGNED DEFAULT 0 NOT NULL,
    cupe_page INTEGER UNSIGNED DEFAULT 0 NOT NULL,
    cupe_timestamp BLOB NOT NULL,
    cupe_ip VARCHAR(255) DEFAULT '',
    cupe_ip_hex VARCHAR(255) DEFAULT NULL,
    cupe_xff BLOB DEFAULT '',
    cupe_xff_hex VARCHAR(255) DEFAULT NULL,
    cupe_agent BLOB DEFAULT NULL,
    cupe_private BLOB DEFAULT NULL
  );
INSERT INTO /*_*/cu_private_event (
    cupe_id, cupe_namespace, cupe_title,
    cupe_actor, cupe_log_type, cupe_log_action,
    cupe_params, cupe_comment_id, cupe_page,
    cupe_timestamp, cupe_ip, cupe_ip_hex,
    cupe_xff, cupe_xff_hex, cupe_agent,
    cupe_private
  )
SELECT
  cupe_id,
  cupe_namespace,
  cupe_title,
  cupe_actor,
  cupe_log_type,
  cupe_log_action,
  cupe_params,
  cupe_comment_id,
  cupe_page,
  cupe_timestamp,
  cupe_ip,
  cupe_ip_hex,
  cupe_xff,
  cupe_xff_hex,
  cupe_agent,
  cupe_private
FROM
  /*_*/__temp__cu_private_event;
DROP TABLE /*_*/__temp__cu_private_event;

CREATE INDEX cupe_ip_hex_time ON /*_*/cu_private_event (cupe_ip_hex, cupe_timestamp);

CREATE INDEX cupe_xff_hex_time ON /*_*/cu_private_event (cupe_xff_hex, cupe_timestamp);

CREATE INDEX cupe_timestamp ON /*_*/cu_private_event (cupe_timestamp);

CREATE INDEX cupe_actor_ip_time ON /*_*/cu_private_event (
    cupe_actor, cupe_ip, cupe_timestamp
  );
