-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: schema/tables-virtual-checkuser.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE cusi_case (
  sic_id SERIAL NOT NULL,
  sic_status SMALLINT DEFAULT 0 NOT NULL,
  sic_status_reason TEXT DEFAULT '' NOT NULL,
  sic_created_timestamp TIMESTAMPTZ NOT NULL,
  PRIMARY KEY(sic_id)
);

CREATE UNIQUE INDEX sic_status_created_timestamp_id ON cusi_case (
  sic_status, sic_created_timestamp,
  sic_id
);

CREATE UNIQUE INDEX sic_created_timestamp_id ON cusi_case (sic_created_timestamp, sic_id);


CREATE TABLE cusi_user (
  siu_user_id INT NOT NULL,
  siu_sic_id INT NOT NULL,
  PRIMARY KEY(siu_sic_id, siu_user_id)
);

CREATE INDEX siu_user_id ON cusi_user (siu_user_id);


CREATE TABLE cusi_signal (
  sis_sic_id INT NOT NULL,
  sis_name TEXT NOT NULL,
  sis_value TEXT NOT NULL,
  PRIMARY KEY(sis_name, sis_value, sis_sic_id)
);

CREATE INDEX sis_sic_id ON cusi_signal (sis_sic_id);
