-- 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 /*_*/flow_workflow (
  workflow_id BINARY(11) NOT NULL,
  workflow_wiki VARBINARY(64) NOT NULL,
  workflow_namespace INT NOT NULL,
  workflow_page_id INT UNSIGNED NOT NULL,
  workflow_title_text VARBINARY(255) NOT NULL,
  workflow_name VARBINARY(255) NOT NULL,
  workflow_last_update_timestamp BINARY(14) NOT NULL,
  workflow_lock_state INT UNSIGNED NOT NULL,
  workflow_type VARBINARY(16) NOT NULL,
  INDEX flow_workflow_lookup (
    workflow_wiki, workflow_namespace,
    workflow_title_text
  ),
  INDEX flow_workflow_update_timestamp (workflow_last_update_timestamp),
  PRIMARY KEY(workflow_id)
) /*$wgDBTableOptions*/;


CREATE TABLE /*_*/flow_topic_list (
  topic_list_id BINARY(11) NOT NULL,
  topic_id BINARY(11) NOT NULL,
  INDEX flow_topic_list_topic_id (topic_id),
  PRIMARY KEY(topic_list_id, topic_id)
) /*$wgDBTableOptions*/;


CREATE TABLE /*_*/flow_tree_revision (
  tree_rev_id BINARY(11) NOT NULL,
  tree_rev_descendant_id BINARY(11) NOT NULL,
  tree_orig_user_id BIGINT UNSIGNED NOT NULL,
  tree_orig_user_ip VARBINARY(39) DEFAULT NULL,
  tree_orig_user_wiki VARBINARY(64) NOT NULL,
  tree_parent_id BINARY(11) DEFAULT NULL,
  INDEX flow_tree_descendant_rev_id (
    tree_rev_descendant_id, tree_rev_id
  ),
  PRIMARY KEY(tree_rev_id)
) /*$wgDBTableOptions*/;


CREATE TABLE /*_*/flow_revision (
  rev_id BINARY(11) NOT NULL,
  rev_type VARBINARY(16) NOT NULL,
  rev_type_id BINARY(11) DEFAULT '' NOT NULL,
  rev_user_id BIGINT UNSIGNED NOT NULL,
  rev_user_ip VARBINARY(39) DEFAULT NULL,
  rev_user_wiki VARBINARY(64) NOT NULL,
  rev_parent_id BINARY(11) DEFAULT NULL,
  rev_flags TINYBLOB NOT NULL,
  rev_content MEDIUMBLOB NOT NULL,
  rev_change_type VARBINARY(255) DEFAULT NULL,
  rev_mod_state VARBINARY(32) NOT NULL,
  rev_mod_user_id BIGINT UNSIGNED DEFAULT NULL,
  rev_mod_user_ip VARBINARY(39) DEFAULT NULL,
  rev_mod_user_wiki VARBINARY(64) DEFAULT NULL,
  rev_mod_timestamp BINARY(14) DEFAULT NULL,
  rev_mod_reason VARBINARY(255) DEFAULT NULL,
  rev_last_edit_id BINARY(11) DEFAULT NULL,
  rev_edit_user_id BIGINT UNSIGNED DEFAULT NULL,
  rev_edit_user_ip VARBINARY(39) DEFAULT NULL,
  rev_edit_user_wiki VARBINARY(64) DEFAULT NULL,
  rev_content_length INT DEFAULT 0 NOT NULL,
  rev_previous_content_length INT DEFAULT 0 NOT NULL,
  UNIQUE INDEX flow_revision_unique_parent (rev_parent_id),
  INDEX flow_revision_type_id (rev_type, rev_type_id),
  INDEX flow_revision_user (
    rev_user_id, rev_user_ip, rev_user_wiki
  ),
  PRIMARY KEY(rev_id)
) /*$wgDBTableOptions*/;


CREATE TABLE /*_*/flow_tree_node (
  tree_ancestor_id BINARY(11) NOT NULL,
  tree_descendant_id BINARY(11) NOT NULL,
  tree_depth SMALLINT NOT NULL,
  UNIQUE INDEX flow_tree_constraint (tree_descendant_id, tree_depth),
  PRIMARY KEY(
    tree_ancestor_id, tree_descendant_id
  )
) /*$wgDBTableOptions*/;


CREATE TABLE /*_*/flow_wiki_ref (
  ref_id BINARY(11) NOT NULL,
  ref_src_wiki VARBINARY(64) NOT NULL,
  ref_src_object_id BINARY(11) NOT NULL,
  ref_src_object_type VARBINARY(32) NOT NULL,
  ref_src_workflow_id BINARY(11) NOT NULL,
  ref_src_namespace INT NOT NULL,
  ref_src_title VARBINARY(255) NOT NULL,
  ref_target_namespace INT NOT NULL,
  ref_target_title VARBINARY(255) NOT NULL,
  ref_type VARBINARY(16) NOT NULL,
  INDEX flow_wiki_ref_idx_v2 (
    ref_src_wiki, ref_src_namespace,
    ref_src_title, ref_type, ref_target_namespace,
    ref_target_title, ref_src_object_type,
    ref_src_object_id
  ),
  INDEX flow_wiki_ref_revision_v2 (
    ref_src_wiki, ref_src_namespace,
    ref_src_title, ref_src_object_type,
    ref_src_object_id, ref_type, ref_target_namespace,
    ref_target_title
  ),
  PRIMARY KEY(ref_id)
) /*$wgDBTableOptions*/;


CREATE TABLE /*_*/flow_ext_ref (
  ref_id BINARY(11) NOT NULL,
  ref_src_wiki VARBINARY(64) NOT NULL,
  ref_src_object_id BINARY(11) NOT NULL,
  ref_src_object_type VARBINARY(32) NOT NULL,
  ref_src_workflow_id BINARY(11) NOT NULL,
  ref_src_namespace INT NOT NULL,
  ref_src_title VARBINARY(255) NOT NULL,
  ref_target BLOB NOT NULL,
  ref_type VARBINARY(16) NOT NULL,
  INDEX flow_ext_ref_idx_v3 (
    ref_src_wiki,
    ref_src_namespace,
    ref_src_title,
    ref_type,
    ref_target(255),
    ref_src_object_type,
    ref_src_object_id
  ),
  INDEX flow_ext_ref_revision_v2 (
    ref_src_wiki,
    ref_src_namespace,
    ref_src_title,
    ref_src_object_type,
    ref_src_object_id,
    ref_type,
    ref_target(255)
  ),
  PRIMARY KEY(ref_id)
) /*$wgDBTableOptions*/;
