-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: sql/discussiontools_persistent.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/discussiontools_items (
  it_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  it_itemname BLOB NOT NULL, it_timestamp BLOB DEFAULT NULL,
  it_actor BIGINT UNSIGNED DEFAULT NULL
);

CREATE UNIQUE INDEX it_itemname ON /*_*/discussiontools_items (it_itemname);


CREATE TABLE /*_*/discussiontools_item_ids (
  itid_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  itid_itemid BLOB NOT NULL
);

CREATE UNIQUE INDEX itid_itemid ON /*_*/discussiontools_item_ids (itid_itemid);


CREATE TABLE /*_*/discussiontools_item_pages (
  itp_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  itp_items_id INTEGER UNSIGNED NOT NULL,
  itp_page_id BIGINT UNSIGNED NOT NULL,
  itp_oldest_revision_id BIGINT UNSIGNED NOT NULL,
  itp_newest_revision_id BIGINT UNSIGNED NOT NULL
);

CREATE UNIQUE INDEX itp_items_id_page_id ON /*_*/discussiontools_item_pages (itp_items_id, itp_page_id);

CREATE UNIQUE INDEX itp_items_id_newest_revision_id ON /*_*/discussiontools_item_pages (
  itp_items_id, itp_newest_revision_id
);


CREATE TABLE /*_*/discussiontools_item_revisions (
  itr_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  itr_itemid_id INTEGER NOT NULL, itr_revision_id BIGINT UNSIGNED NOT NULL,
  itr_items_id INTEGER NOT NULL, itr_parent_id INTEGER DEFAULT NULL,
  itr_transcludedfrom BIGINT UNSIGNED DEFAULT NULL,
  itr_level SMALLINT NOT NULL, itr_headinglevel SMALLINT DEFAULT NULL
);

CREATE INDEX itr_revision_id ON /*_*/discussiontools_item_revisions (itr_revision_id);

CREATE UNIQUE INDEX itr_itemid_id_revision_id ON /*_*/discussiontools_item_revisions (itr_itemid_id, itr_revision_id);
