Skip to content

speed up project removal

#!/bin/bash

PROJECT_ID=5943
PROJECT_ID=5960
PROJECT_ID=5971
PROJECT_ID=5982
PROJECT_ID=5991
PROJECT_ID=5995
PROJECT_ID=6033
PROJECT_ID=3938
#PROJECT_ID=6009
#PROJECT_ID=6042

psql -c "delete from data_overlay_entry_compartment_table where data_overlay_entry_id in (select id from data_overlay_entry_table where data_overlay_id in (select id from data_overlay_table where project_id= $PROJECT_ID))";
psql -c "delete from gene_variant_table where data_overlay_entry_id in (select id from data_overlay_entry_table where data_overlay_id in (select id from data_overlay_table where project_id= $PROJECT_ID))";
psql -c "delete from data_overlay_entry_miriam_table where data_overlay_entry_id in (select id from data_overlay_entry_table where data_overlay_id in (select id from data_overlay_table where project_id= $PROJECT_ID))";
psql -c "delete from data_overlay_entry_table where data_overlay_id in (select id from data_overlay_table where project_id= $PROJECT_ID)";
psql -c "delete from data_overlay_table where project_id= $PROJECT_ID";

psql -c "delete from project_background_image_layer_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID)";

psql -c "update element_table set submodel_id = null where model_id in (select id from model_data_table where project_id= $PROJECT_ID)";
psql -c "delete from submodel_connection_table where from_element_id in (select  id from element_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID))";
psql -c "delete from submodel_connection_table where submodel_id in (select id from model_data_table where project_id= $PROJECT_ID)";
psql -c "delete from element_miriam where element_id in (select  id from element_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID))";
psql -c "delete from element_miriam where element_id in (select  id from element_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID))";
psql -c "delete from element_synonyms where id in (select  id from element_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID))";
psql -c "delete from element_former_symbols where id in (select  id from element_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID))";
psql -c "delete from reaction_node_table where element_id in (select  id from element_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID))";
psql -c "delete from modification_residue_table where id_species_db in (select  id from element_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID))";
psql -c "delete from element_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID)";

psql -c "delete from reaction_miriam where reaction_id in (select  id from reaction_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID))";
psql -c "delete from reaction_node_table where reaction_id in (select  id from reaction_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID))";
psql -c "delete from reaction_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID)";

psql -c "delete from layer_text_table where glyph_id in (select id from glyph_table where project_id= $PROJECT_ID)";
psql -c "delete from layer_table_texts where layer_table_id in (select id from layer_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID))";
psql -c "delete from layer_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID)";

psql -c "delete from comment_table where model_id in (select id from model_data_table where project_id= $PROJECT_ID)";

psql -c "delete from overview_link_table where linked_model_id in (select id from model_data_table where project_id= $PROJECT_ID)";

psql -c "update project_table set top_model_id = null where id = $PROJECT_ID";
psql -c "delete from model_data_table where project_id= $PROJECT_ID";

psql -c "delete from project_background_table where project_id= $PROJECT_ID";
psql -c "delete from project_log_entry_table where project_id= $PROJECT_ID";

psql -c "delete from glyph_table where project_id= $PROJECT_ID";

psql -c "delete from project_table where id = $PROJECT_ID";
psql -c "vacuum full analyze";
Edited by Piotr Gawron