-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: sql/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE globaljsonlinks_target (
  gjlt_id BIGSERIAL NOT NULL,
  gjlt_namespace INT NOT NULL,
  gjlt_title TEXT NOT NULL,
  PRIMARY KEY(gjlt_id)
);

CREATE UNIQUE INDEX gjlt_namespace_title ON globaljsonlinks_target (gjlt_namespace, gjlt_title);


CREATE TABLE globaljsonlinks_wiki (
  gjlw_id SERIAL NOT NULL,
  gjlw_wiki TEXT NOT NULL,
  gjlw_namespace INT DEFAULT NULL,
  gjlw_namespace_text TEXT DEFAULT NULL,
  PRIMARY KEY(gjlw_id)
);

CREATE UNIQUE INDEX gjlw_wiki_id_namespace ON globaljsonlinks_wiki (
  gjlw_wiki, gjlw_namespace, gjlw_namespace_text
);


CREATE TABLE globaljsonlinks (
  gjl_wiki INT NOT NULL,
  gjl_namespace INT NOT NULL,
  gjl_title TEXT NOT NULL,
  gjl_target BIGINT NOT NULL,
  PRIMARY KEY(
    gjl_wiki, gjl_namespace, gjl_title,
  gjl_target
  )
);

CREATE INDEX gjl_target_namespace_title ON globaljsonlinks (
  gjl_target, gjl_wiki, gjl_namespace,
  gjl_title
);
