-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: sql/abstractSchemaChanges/patch-uploadstash-us_size_to_bigint.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__uploadstash AS
SELECT
  us_id,
  us_user,
  us_key,
  us_orig_path,
  us_path,
  us_source_type,
  us_timestamp,
  us_status,
  us_chunk_inx,
  us_props,
  us_size,
  us_sha1,
  us_mime,
  us_media_type,
  us_image_width,
  us_image_height,
  us_image_bits
FROM /*_*/uploadstash;

DROP TABLE /*_*/uploadstash;


CREATE TABLE /*_*/uploadstash (
  us_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  us_user INTEGER UNSIGNED NOT NULL,
  us_key VARCHAR(255) NOT NULL,
  us_orig_path VARCHAR(255) NOT NULL,
  us_path VARCHAR(255) NOT NULL,
  us_source_type VARCHAR(50) DEFAULT NULL,
  us_timestamp BLOB NOT NULL,
  us_status VARCHAR(50) NOT NULL,
  us_chunk_inx INTEGER UNSIGNED DEFAULT NULL,
  us_props BLOB DEFAULT NULL,
  us_size BIGINT UNSIGNED NOT NULL,
  us_sha1 VARCHAR(31) NOT NULL,
  us_mime VARCHAR(255) DEFAULT NULL,
  us_media_type TEXT DEFAULT NULL,
  us_image_width INTEGER UNSIGNED DEFAULT NULL,
  us_image_height INTEGER UNSIGNED DEFAULT NULL,
  us_image_bits SMALLINT UNSIGNED DEFAULT NULL
);

INSERT INTO /*_*/uploadstash (
  us_id, us_user, us_key, us_orig_path,
  us_path, us_source_type, us_timestamp,
  us_status, us_chunk_inx, us_props,
  us_size, us_sha1, us_mime, us_media_type,
  us_image_width, us_image_height,
  us_image_bits
)
SELECT
  us_id,
  us_user,
  us_key,
  us_orig_path,
  us_path,
  us_source_type,
  us_timestamp,
  us_status,
  us_chunk_inx,
  us_props,
  us_size,
  us_sha1,
  us_mime,
  us_media_type,
  us_image_width,
  us_image_height,
  us_image_bits
FROM
  /*_*/__temp__uploadstash;

DROP TABLE /*_*/__temp__uploadstash;

CREATE INDEX us_user ON /*_*/uploadstash (us_user);

CREATE UNIQUE INDEX us_key ON /*_*/uploadstash (us_key);

CREATE INDEX us_timestamp ON /*_*/uploadstash (us_timestamp);
