-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/CheckUser/schema/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_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_user INTEGER DEFAULT 0 NOT NULL,
  cuc_user_text VARCHAR(255) DEFAULT '' NOT NULL,
  cuc_actor BIGINT UNSIGNED DEFAULT 0 NOT NULL,
  cuc_actiontext BLOB DEFAULT '' NOT NULL,
  cuc_comment BLOB DEFAULT '' NOT NULL,
  cuc_comment_id BIGINT UNSIGNED DEFAULT 0 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_private BLOB DEFAULT NULL
);

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

CREATE INDEX cuc_user_ip_time ON /*_*/cu_changes (cuc_user, cuc_ip, 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);


CREATE TABLE /*_*/cu_log (
  cul_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  cul_timestamp BLOB NOT NULL, cul_user INTEGER UNSIGNED NOT NULL,
  cul_user_text BLOB NOT NULL, cul_actor BIGINT UNSIGNED DEFAULT 0 NOT NULL,
  cul_reason BLOB 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
);

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

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);
