diff --git a/database/data.sql b/database/misc/data.sql similarity index 99% rename from database/data.sql rename to database/misc/data.sql index 9d62e65..df9c412 100644 --- a/database/data.sql +++ b/database/misc/data.sql @@ -8,4 +8,3 @@ INSERT INTO `unipept`.`users` (`id`, `username`, `admin`) VALUES (2, 'pdawyndt', INSERT INTO `unipept`.`users` (`id`, `username`, `admin`) VALUES (3, 'guest', 0); COMMIT; - diff --git a/database/db_model.mwb b/database/misc/db_model.mwb similarity index 100% rename from database/db_model.mwb rename to database/misc/db_model.mwb diff --git a/database/headers.md b/database/misc/headers.md similarity index 100% rename from database/headers.md rename to database/misc/headers.md diff --git a/database/load_compress.sh b/database/misc/load_compress.sh similarity index 100% rename from database/load_compress.sh rename to database/misc/load_compress.sh diff --git a/database/sample_data.sql b/database/misc/sample_data.sql similarity index 100% rename from database/sample_data.sql rename to database/misc/sample_data.sql diff --git a/database/structure_index_only.sql b/database/misc/structure_index_only.sql similarity index 100% rename from database/structure_index_only.sql rename to database/misc/structure_index_only.sql diff --git a/database/structure_no_index.sql b/database/misc/structure_no_index.sql similarity index 100% rename from database/structure_no_index.sql rename to database/misc/structure_no_index.sql diff --git a/database/structure_no_index_compress.sql b/database/misc/structure_no_index_compress.sql similarity index 100% rename from database/structure_no_index_compress.sql rename to database/misc/structure_no_index_compress.sql diff --git a/database/swap_databases.sql b/database/swap_databases.sql deleted file mode 100644 index 68c82e5..0000000 --- a/database/swap_databases.sql +++ /dev/null @@ -1,32 +0,0 @@ -drop table - ec_cross_references, - ec_numbers, - embl_cross_references, - go_cross_references, - go_terms, - lineages, - peptides, - refseq_cross_references, - sequences, - taxons, - uniprot_entries, - proteomes, - proteome_cross_references, - proteome_caches; - -rename table unipept2.ec_cross_references to unipept.ec_cross_references; -rename table unipept2.ec_numbers to unipept.ec_numbers; -rename table unipept2.embl_cross_references to unipept.embl_cross_references; -rename table unipept2.go_cross_references to unipept.go_cross_references; -rename table unipept2.go_terms to unipept.go_terms; -rename table unipept2.lineages to unipept.lineages; -rename table unipept2.peptides to unipept.peptides; -rename table unipept2.refseq_cross_references to unipept.refseq_cross_references; -rename table unipept2.sequences to unipept.sequences; -# rename table unipept2.sequences_compressed to unipept.sequences_compressed; -# NOTE: a view cannot be renamed! Create it separately (see structure_no_index_compress.sql) -rename table unipept2.taxons to unipept.taxons; -rename table unipept2.uniprot_entries to unipept.uniprot_entries; -rename table unipept2.proteomes to unipept.proteomes; -rename table unipept2.proteome_cross_references to unipept.proteome_cross_references; -rename table unipept2.proteome_caches to unipept.proteome_caches; diff --git a/database/upgrade/README.md b/database/upgrade/README.md new file mode 100644 index 0000000..97c2a62 --- /dev/null +++ b/database/upgrade/README.md @@ -0,0 +1,3 @@ +This file contains all scripts, completely preconfigured, to upgrade the database on our Unipept production server. See +the main [Unipept wiki](https://github.com/unipept/unipept/wiki/Update-Unipept-database) for more information on how +to do this. diff --git a/database/index.sh b/database/upgrade/index.sh similarity index 94% rename from database/index.sh rename to database/upgrade/index.sh index c55aa4d..3f24bbe 100755 --- a/database/index.sh +++ b/database/upgrade/index.sh @@ -17,7 +17,7 @@ function print { function doCmd { echo -n "-> " print "$1" - echo $1 | mysql -u unipept -punipept unipept 2>&1 | sed "s/^/ /" | grep -v "Using a password on the command line interface can be insecure" | tee -a $logfile + echo $1 | mysql -u unipept -punipept unipept2 2>&1 | sed "s/^/ /" | grep -v "Using a password on the command line interface can be insecure" | tee -a $logfile } diff --git a/database/load.sh b/database/upgrade/load.sh similarity index 76% rename from database/load.sh rename to database/upgrade/load.sh index ca12262..73775c9 100755 --- a/database/load.sh +++ b/database/upgrade/load.sh @@ -2,12 +2,15 @@ # extracts all .tsv.gz files, imports them into the unipept database # and removes the files -db=unipept +# Directory from which the .tsv.gz files should be read and parsed (= first argument to this script). +dir="$1" +db=unipept2 function print { echo $(date -u) $1 } +cd "$dir" for file in *.tsv.gz do @@ -17,3 +20,5 @@ do zcat $file | mysql --local-infile=1 -uunipept -punipept $db -e "LOAD DATA LOCAL INFILE '/dev/stdin' INTO TABLE $tbl;SHOW WARNINGS" 2>&1 done print "done" + +cd - diff --git a/database/structure.sql b/database/upgrade/structure.sql similarity index 100% rename from database/structure.sql rename to database/upgrade/structure.sql diff --git a/database/upgrade/structure_no_index.sql b/database/upgrade/structure_no_index.sql new file mode 100644 index 0000000..3a20827 --- /dev/null +++ b/database/upgrade/structure_no_index.sql @@ -0,0 +1,353 @@ +SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; + +-- Drop the old database. This database will be recreated further on during this script! +DROP DATABASE IF EXISTS `unipept2`; + +CREATE SCHEMA IF NOT EXISTS `unipept2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; +USE `unipept2` ; + +-- ----------------------------------------------------- +-- Table `unipept2`.`taxons` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`taxons` ( + `id` MEDIUMINT UNSIGNED NOT NULL , + `name` VARCHAR(120) NOT NULL , + `rank` ENUM('no rank', 'superkingdom', 'kingdom', 'subkingdom', 'superphylum', 'phylum', 'subphylum', 'superclass', 'class', 'subclass', 'superorder', 'order', 'suborder', 'infraorder', 'superfamily', 'family', 'subfamily', 'tribe', 'subtribe', 'genus', 'subgenus', 'species group', 'species subgroup', 'species', 'subspecies', 'strain', 'varietas', 'forma' ) NULL DEFAULT NULL , + `parent_id` MEDIUMINT UNSIGNED NULL DEFAULT NULL , + `valid_taxon` BIT NOT NULL DEFAULT 1 , + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8 +COLLATE = utf8_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`uniprot_entries` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`uniprot_entries` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `uniprot_accession_number` CHAR(10) ASCII NOT NULL , + `version` SMALLINT UNSIGNED NOT NULL , + `taxon_id` MEDIUMINT UNSIGNED NOT NULL , + `type` ENUM('swissprot', 'trembl') NOT NULL , + `name`VARCHAR(150) NOT NULL , + `protein` TEXT NOT NULL , + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`ec_numbers` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`ec_numbers` ( + `id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, + `code` VARCHAR(15) NOT NULL, + `name` VARCHAR(155) NOT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8 +COLLATE = utf8_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`go_terms` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`go_terms` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `code` VARCHAR(15) NOT NULL, + `namespace` ENUM('biological process', 'molecular function', 'cellular component') NOT NULL, + `name` VARCHAR(200) NOT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`uniprot_entries` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`uniprot_entries` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `uniprot_accession_number` CHAR(10) ASCII NOT NULL , + `version` SMALLINT UNSIGNED NOT NULL , + `taxon_id` MEDIUMINT UNSIGNED NOT NULL , + `type` ENUM('swissprot', 'trembl') NOT NULL , + `name`VARCHAR(150) NOT NULL , + `protein` TEXT NOT NULL , + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8 +COLLATE = utf8_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`lineages` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`lineages` ( + `taxon_id` MEDIUMINT UNSIGNED NOT NULL , + `superkingdom` MEDIUMINT NULL DEFAULT NULL , + `kingdom` MEDIUMINT NULL DEFAULT NULL , + `subkingdom` MEDIUMINT NULL DEFAULT NULL , + `superphylum` MEDIUMINT NULL DEFAULT NULL , + `phylum` MEDIUMINT NULL DEFAULT NULL , + `subphylum` MEDIUMINT NULL DEFAULT NULL , + `superclass` MEDIUMINT NULL DEFAULT NULL , + `class` MEDIUMINT NULL DEFAULT NULL , + `subclass` MEDIUMINT NULL DEFAULT NULL , + `superorder` MEDIUMINT NULL DEFAULT NULL , + `order` MEDIUMINT NULL DEFAULT NULL , + `suborder` MEDIUMINT NULL DEFAULT NULL , + `infraorder` MEDIUMINT NULL DEFAULT NULL , + `superfamily` MEDIUMINT NULL DEFAULT NULL , + `family` MEDIUMINT NULL DEFAULT NULL , + `subfamily` MEDIUMINT NULL DEFAULT NULL , + `tribe` MEDIUMINT NULL DEFAULT NULL , + `subtribe` MEDIUMINT NULL DEFAULT NULL , + `genus` MEDIUMINT NULL DEFAULT NULL , + `subgenus` MEDIUMINT NULL DEFAULT NULL , + `species_group` MEDIUMINT NULL DEFAULT NULL , + `species_subgroup` MEDIUMINT NULL DEFAULT NULL , + `species` MEDIUMINT NULL DEFAULT NULL , + `subspecies` MEDIUMINT NULL DEFAULT NULL , + `strain` MEDIUMINT NULL DEFAULT NULL , + `varietas` MEDIUMINT NULL DEFAULT NULL , + `forma` MEDIUMINT NULL DEFAULT NULL , + PRIMARY KEY (`taxon_id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`sequences` +-- BLOCKSIZE 16 IS DEFAULT BLOCKSIZE +-- Only BLOBS will get compressed +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`sequences` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `sequence` VARCHAR(50) NOT NULL , + `lca` MEDIUMINT UNSIGNED NULL , + `lca_il` MEDIUMINT UNSIGNED NULL , + `fa` MEDIUMBLOB NULL , + `fa_il` MEDIUMBLOB NULL , + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16 +COLLATE = ascii_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`peptides` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`peptides` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `sequence_id` INT UNSIGNED NOT NULL , + `original_sequence_id` INT UNSIGNED NOT NULL , + `uniprot_entry_id` INT UNSIGNED NOT NULL , + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`embl_cross_references` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`embl_cross_references` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `uniprot_entry_id` INT UNSIGNED NOT NULL , + `protein_id` VARCHAR(25) NULL , + `sequence_id` VARCHAR(25) NULL , + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`datasets` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`datasets` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `environment` VARCHAR(160) NULL , + `reference` VARCHAR(500) NULL , + `url` VARCHAR(200) NULL , + `project_website` VARCHAR(200) NULL , + PRIMARY KEY (`id`) ) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8 +COLLATE = utf8_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`dataset_items` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`dataset_items` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `dataset_id` INT UNSIGNED NULL , + `name` VARCHAR(160) NULL , + `data` MEDIUMTEXT CHARACTER SET 'ascii' COLLATE 'ascii_general_ci' NOT NULL , + `order` INT NULL , + PRIMARY KEY (`id`) , + INDEX `fk_dataset_items_datasets` (`dataset_id` ASC) , + CONSTRAINT `fk_dataset_items_datasets` + FOREIGN KEY (`dataset_id` ) + REFERENCES `unipept2`.`datasets` (`id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8 +COLLATE = utf8_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`posts` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`posts` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `title` VARCHAR(100) NOT NULL , + `content` TEXT NOT NULL , + `date` DATE NOT NULL , + PRIMARY KEY (`id`) ) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8 +COLLATE = utf8_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`refseq_cross_references` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`refseq_cross_references` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `uniprot_entry_id` INT UNSIGNED NOT NULL , + `protein_id` VARCHAR(25) NULL , + `sequence_id` VARCHAR(25) NULL , + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`go_cross_references` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`go_cross_references` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `uniprot_entry_id` INT UNSIGNED NOT NULL , + `go_term_code` VARCHAR(15) NOT NULL , + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`go_terms` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`go_terms` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `go_term_code` VARCHAR(15) NOT NULL, + `name` VARCHAR(160) NOT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`ec_cross_references` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`ec_cross_references` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `uniprot_entry_id` INT UNSIGNED NOT NULL , + `ec_number_code` VARCHAR(15) NOT NULL , + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + +-- ----------------------------------------------------- +-- Table `unipept2`.`interpro_cross_references` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`interpro_cross_references` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `uniprot_entry_id` INT UNSIGNED NOT NULL , + `interpro_entry_code` VARCHAR(9) NOT NULL , + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`interpro` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`interpro_entries` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `code` VARCHAR(9) NOT NULL, + `category` VARCHAR(32) NOT NULL, + `name` VARCHAR(160) NOT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`users` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`users` ( + `id` INT NOT NULL AUTO_INCREMENT, + `username` VARCHAR(8) NOT NULL, + `admin` TINYINT NOT NULL DEFAULT 0, + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + +-- ----------------------------------------------------- +-- Table `unipept2`.`proteomes` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`proteomes` ( + `id` MEDIUMINT UNSIGNED NOT NULL, + `proteome_accession_number` CHAR(12) NOT NULL, + `proteome_name` VARCHAR(145) NOT NULL, + `taxon_id` MEDIUMINT UNSIGNED NULL, + `type_strain` BIT(1) NOT NULL DEFAULT b'0', + `reference_proteome` BIT(1) NOT NULL DEFAULT b'0', + `strain` VARCHAR(120) NULL, + `assembly` VARCHAR(45) NULL, + `name` VARCHAR(225) NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8 +COLLATE = utf8_general_ci; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`proteome_cross_references` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`proteome_cross_references` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `uniprot_entry_id` INT UNSIGNED NOT NULL, + `proteome_id` MEDIUMINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `unipept2`.`proteome_caches` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `unipept2`.`proteome_caches` ( + `proteome_id` MEDIUMINT UNSIGNED NOT NULL, + `json_sequences` MEDIUMTEXT NOT NULL, + PRIMARY KEY (`proteome_id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = ascii +COLLATE = ascii_general_ci; + + +SET SQL_MODE=@OLD_SQL_MODE; +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; diff --git a/database/upgrade/swap_databases.sql b/database/upgrade/swap_databases.sql new file mode 100644 index 0000000..7c9b25c --- /dev/null +++ b/database/upgrade/swap_databases.sql @@ -0,0 +1,63 @@ +-- First create a new table `unipept3` that will temporary hold all the required information from the previous UniProt +-- version (that is still in the `unipept` database). + +CREATE SCHEMA `unipept3` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; + +-- Now, move the tables from `unipept` to `unipept3` before continueing. `unipept3` will thus temporary hold all the +-- backup data for the database. +RENAME TABLE unipept.ec_cross_references TO unipept3.ec_cross_references; +RENAME TABLE unipept.ec_numbers TO unipept3.ec_numbers; +RENAME TABLE unipept.interpro_cross_references TO unipept3.interpro_cross_references; +RENAME TABLE unipept.interpro_entries TO unipept3.interpro_entries; +RENAME TABLE unipept.embl_cross_references TO unipept3.embl_cross_references; +RENAME TABLE unipept.go_cross_references TO unipept3.go_cross_references; +RENAME TABLE unipept.go_terms TO unipept3.go_terms; +RENAME TABLE unipept.lineages TO unipept3.lineages; +RENAME TABLE unipept.peptides TO unipept3.peptides; +RENAME TABLE unipept.refseq_cross_references TO unipept3.refseq_cross_references; +RENAME TABLE unipept.sequences TO unipept3.sequences; +RENAME TABLE unipept.taxons TO unipept3.taxons; +RENAME TABLE unipept.uniprot_entries TO unipept3.uniprot_entries; +RENAME TABLE unipept.proteomes TO unipept3.proteomes; +RENAME TABLE unipept.proteome_cross_references TO unipept3.proteome_cross_references; +RENAME TABLE unipept.proteome_caches TO unipept3.proteome_caches; + +-- Move the most recent UniProt release data to the current production database (`unipept`) +RENAME TABLE unipept2.ec_cross_references TO unipept.ec_cross_references; +RENAME TABLE unipept2.ec_numbers TO unipept.ec_numbers; +RENAME TABLE unipept2.interpro_cross_references TO unipept.interpro_cross_references; +RENAME TABLE unipept2.interpro_entries TO unipept.interpro_entries; +RENAME TABLE unipept2.embl_cross_references TO unipept.embl_cross_references; +RENAME TABLE unipept2.go_cross_references TO unipept.go_cross_references; +RENAME TABLE unipept2.go_terms TO unipept.go_terms; +RENAME TABLE unipept2.lineages TO unipept.lineages; +RENAME TABLE unipept2.peptides TO unipept.peptides; +RENAME TABLE unipept2.refseq_cross_references TO unipept.refseq_cross_references; +RENAME TABLE unipept2.sequences TO unipept.sequences; +RENAME TABLE unipept2.taxons TO unipept.taxons; +RENAME TABLE unipept2.uniprot_entries TO unipept.uniprot_entries; +RENAME TABLE unipept2.proteomes TO unipept.proteomes; +RENAME TABLE unipept2.proteome_cross_references TO unipept.proteome_cross_references; +RENAME TABLE unipept2.proteome_caches TO unipept.proteome_caches; + +-- Finally, move the temporary table (`unipept3`) back to `unipept2` (`unipept` always holds a copy of the previous +-- UniProt release. This way we can easily rollback to a previous version of the database in case something is wrong.) +RENAME TABLE unipept3.ec_cross_references TO unipept2.ec_cross_references; +RENAME TABLE unipept3.ec_numbers TO unipept2.ec_numbers; +RENAME TABLE unipept3.interpro_cross_references TO unipept2.interpro_cross_references; +RENAME TABLE unipept3.interpro_entries TO unipept2.interpro_entries; +RENAME TABLE unipept3.embl_cross_references TO unipept2.embl_cross_references; +RENAME TABLE unipept3.go_cross_references TO unipept2.go_cross_references; +RENAME TABLE unipept3.go_terms TO unipept2.go_terms; +RENAME TABLE unipept3.lineages TO unipept2.lineages; +RENAME TABLE unipept3.peptides TO unipept2.peptides; +RENAME TABLE unipept3.refseq_cross_references TO unipept2.refseq_cross_references; +RENAME TABLE unipept3.sequences TO unipept2.sequences; +RENAME TABLE unipept3.taxons TO unipept2.taxons; +RENAME TABLE unipept3.uniprot_entries TO unipept2.uniprot_entries; +RENAME TABLE unipept3.proteomes TO unipept2.proteomes; +RENAME TABLE unipept3.proteome_cross_references TO unipept2.proteome_cross_references; +RENAME TABLE unipept3.proteome_caches TO unipept2.proteome_caches; + +-- Remove the temporary database `unipept3`. This database is empty now, and is no longer required. +DROP DATABASE IF EXISTS `unipept3`;