-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: schema/abstractSchemaChanges/patch-cu_log-drop-actor_default.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__cu_log AS
SELECT
  cul_id,
  cul_timestamp,
  cul_actor,
  cul_reason,
  cul_reason_id,
  cul_reason_plaintext_id,
  cul_type,
  cul_target_id,
  cul_target_text,
  cul_target_hex,
  cul_range_start,
  cul_range_end
FROM /*_*/cu_log;

DROP TABLE /*_*/cu_log;


CREATE TABLE /*_*/cu_log (
  cul_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  cul_timestamp BLOB NOT NULL, cul_actor BIGINT UNSIGNED NOT NULL,
  cul_reason BLOB DEFAULT '' NOT NULL,
  cul_reason_id BIGINT UNSIGNED DEFAULT 0 NOT NULL,
  cul_reason_plaintext_id BIGINT UNSIGNED DEFAULT 0 NOT NULL,
  cul_type BLOB NOT NULL, cul_target_id INTEGER UNSIGNED DEFAULT 0 NOT NULL,
  cul_target_text BLOB NOT NULL, cul_target_hex BLOB DEFAULT '' NOT NULL,
  cul_range_start BLOB DEFAULT '' NOT NULL,
  cul_range_end BLOB DEFAULT '' NOT NULL
);

INSERT INTO /*_*/cu_log (
  cul_id, cul_timestamp, cul_actor,
  cul_reason, cul_reason_id, cul_reason_plaintext_id,
  cul_type, cul_target_id, cul_target_text,
  cul_target_hex, cul_range_start,
  cul_range_end
)
SELECT
  cul_id,
  cul_timestamp,
  cul_actor,
  cul_reason,
  cul_reason_id,
  cul_reason_plaintext_id,
  cul_type,
  cul_target_id,
  cul_target_text,
  cul_target_hex,
  cul_range_start,
  cul_range_end
FROM
  /*_*/__temp__cu_log;

DROP TABLE /*_*/__temp__cu_log;

CREATE INDEX cul_actor_time ON /*_*/cu_log (cul_actor, cul_timestamp);

CREATE INDEX cul_type_target ON /*_*/cu_log (
  cul_type, cul_target_id, cul_timestamp
);

CREATE INDEX cul_target_hex ON /*_*/cu_log (cul_target_hex, cul_timestamp);

CREATE INDEX cul_range_start ON /*_*/cu_log (cul_range_start, cul_timestamp);

CREATE INDEX cul_timestamp ON /*_*/cu_log (cul_timestamp);
