-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: sql/abstractSchemaChanges/patch-archive-drop-ar_sha1.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__archive AS
SELECT
  ar_id,
  ar_namespace,
  ar_title,
  ar_comment_id,
  ar_actor,
  ar_timestamp,
  ar_minor_edit,
  ar_rev_id,
  ar_deleted,
  ar_len,
  ar_page_id,
  ar_parent_id
FROM /*_*/archive;

DROP TABLE /*_*/archive;


CREATE TABLE /*_*/archive (
  ar_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  ar_namespace INTEGER DEFAULT 0 NOT NULL,
  ar_title BLOB DEFAULT '' NOT NULL, ar_comment_id BIGINT UNSIGNED NOT NULL,
  ar_actor BIGINT UNSIGNED NOT NULL,
  ar_timestamp BLOB NOT NULL, ar_minor_edit SMALLINT DEFAULT 0 NOT NULL,
  ar_rev_id INTEGER UNSIGNED NOT NULL,
  ar_deleted SMALLINT UNSIGNED DEFAULT 0 NOT NULL,
  ar_len INTEGER UNSIGNED DEFAULT NULL,
  ar_page_id INTEGER UNSIGNED DEFAULT NULL,
  ar_parent_id INTEGER UNSIGNED DEFAULT NULL
);

INSERT INTO /*_*/archive (
  ar_id, ar_namespace, ar_title, ar_comment_id,
  ar_actor, ar_timestamp, ar_minor_edit,
  ar_rev_id, ar_deleted, ar_len, ar_page_id,
  ar_parent_id
)
SELECT
  ar_id,
  ar_namespace,
  ar_title,
  ar_comment_id,
  ar_actor,
  ar_timestamp,
  ar_minor_edit,
  ar_rev_id,
  ar_deleted,
  ar_len,
  ar_page_id,
  ar_parent_id
FROM /*_*/__temp__archive;

DROP TABLE /*_*/__temp__archive;

CREATE INDEX ar_name_title_timestamp ON /*_*/archive (
  ar_namespace, ar_title, ar_timestamp
);

CREATE INDEX ar_actor_timestamp ON /*_*/archive (ar_actor, ar_timestamp);

CREATE UNIQUE INDEX ar_revid_uniq ON /*_*/archive (ar_rev_id);
