From 88c04ec5be5cc53e5b80760546d0106ed4d26ff8 Mon Sep 17 00:00:00 2001
From: Albert Vilella <avilella@ebi.ac.uk>
Date: Mon, 4 Sep 2006 10:18:39 +0000
Subject: [PATCH] adding a remove_analysis_id method that will DELETE FROM
 analysis, analysis_stats, and analysis_job table WHERE analysis_id equals the
 number given

---
 .../EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm  | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm
index 5e668c42f..51acd9af2 100644
--- a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm
+++ b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm
@@ -647,6 +647,34 @@ sub reset_all_jobs_for_analysis_id {
   $self->db->get_AnalysisStatsAdaptor->update_status($analysis_id, 'LOADING');
 }
 
+=head2 remove_analysis_id
+
+  Arg [1]    : int $analysis_id
+  Example    :
+  Description: Remove the analysis from the database.
+               Jobs should have been killed before.
+  Exceptions : $analysis_id must be defined
+  Caller     :
+
+=cut
+
+sub remove_analysis_id {
+  my $self        = shift;
+  my $analysis_id = shift;
+
+  throw("must define analysis_id") unless($analysis_id);
+
+  my $sql;
+  #first just reset the claimed jobs, these don't need a retry_count index increment
+  $sql = "DELETE FROM analysis WHERE analysis_id=$analysis_id";
+  $self->dbc->do($sql);
+  $sql = "DELETE FROM analysis_stats WHERE analysis_id=$analysis_id";
+  $self->dbc->do($sql);
+  $sql = "DELETE FROM analysis_job WHERE analysis_id=$analysis_id";
+  $self->dbc->do($sql);
+
+}
+
 
 1;
 
-- 
GitLab