-- 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 /*_*/nl_newsletters (
  nl_id INT UNSIGNED AUTO_INCREMENT NOT NULL,
  nl_name VARCHAR(64) NOT NULL,
  nl_desc BLOB DEFAULT NULL,
  nl_main_page_id INT UNSIGNED NOT NULL,
  nl_active TINYINT(1) DEFAULT 1 NOT NULL,
  nl_subscriber_count INT DEFAULT 0 NOT NULL,
  INDEX nl_name (nl_name),
  INDEX nl_main_page_active (nl_main_page_id, nl_active),
  INDEX nl_active (nl_active),
  INDEX nl_active_subscriber_name (
    nl_active, nl_subscriber_count, nl_name
  ),
  PRIMARY KEY(nl_id)
) /*$wgDBTableOptions*/;


CREATE TABLE /*_*/nl_issues (
  nli_issue_id INT UNSIGNED NOT NULL,
  nli_newsletter_id INT NOT NULL,
  nli_page_id INT NOT NULL,
  nli_publisher_id INT NOT NULL,
  PRIMARY KEY(nli_newsletter_id, nli_issue_id)
) /*$wgDBTableOptions*/;


CREATE TABLE /*_*/nl_subscriptions (
  nls_newsletter_id INT NOT NULL,
  nls_subscriber_id INT NOT NULL,
  INDEX nls_subscriber_id (nls_subscriber_id),
  PRIMARY KEY(
    nls_newsletter_id, nls_subscriber_id
  )
) /*$wgDBTableOptions*/;


CREATE TABLE /*_*/nl_publishers (
  nlp_newsletter_id INT UNSIGNED NOT NULL,
  nlp_publisher_id INT NOT NULL,
  INDEX nlp_nl_id (nlp_newsletter_id),
  PRIMARY KEY(
    nlp_publisher_id, nlp_newsletter_id
  )
) /*$wgDBTableOptions*/;
