Skip to content
Snippets Groups Projects
Commit c11b9922 authored by Monika Komorowska's avatar Monika Komorowska
Browse files

Delete entries from db for releases older than previous release.

parent 3e64940f
No related branches found
No related tags found
No related merge requests found
......@@ -64,7 +64,8 @@ About:
Given at least a release number, this program will discover new
databases on the staging servers and add them to the list of databases
in the production database on the master server.
in the production database on the master server. It will also delete any old
databases from the list up to the previous realease.
The default options are set to minimize hassle for the Ensembl release
coordinator who needs to run this script during the Ensembl production
......@@ -91,7 +92,7 @@ my ( $dbuser, $dbpass ) = ( 'ensro', undef );
my $opt_help = 0;
my $opt_about = 0;
if ( !GetOptions( 'release|r=s' => \$release,
if ( !GetOptions( 'release|r=i' => \$release,
'master|m=s' => \$master,
'mport|mP=i' => \$mport,
'server|s=s@' => \@servers,
......@@ -125,12 +126,26 @@ my %databases;
my %existing_databases;
my %found_databases;
{
my $dsn = sprintf( 'DBI:mysql:host=%s;port=%d;database=%s',
$master, $mport, 'ensembl_production' );
my $dbh = DBI->connect( $dsn, $dbuser, $dbpass,
my $dbh = DBI->connect( $dsn, $dbwuser, $dbwpass,
{ 'PrintError' => 1, 'RaiseError' => 1 } );
{
my $previous_release = $release - 1;
print "Delete entries from db and db_list for releases older than ". $previous_release ."? (y/n)\n";
my $response = <>;
chomp $response;
if ($response eq 'y'){
$dbh->do("DELETE FROM db WHERE db_release < $previous_release");
}
}
{
my $statement =
'SELECT species_id, web_name, db_name '
......@@ -230,6 +245,7 @@ foreach my $server (@servers) {
if ( scalar( keys(%databases) ) == 0 ) {
printf( "Did not find any new databases for release %s\n", $release );
} else {
my $dsn = sprintf( 'DBI:mysql:host=%s;port=%d;database=%s',
$master, $mport, 'ensembl_production' );
my $dbh = DBI->connect( $dsn, $dbwuser, $dbwpass,
......@@ -275,8 +291,4 @@ if ( scalar( keys(%existing_databases) ) !=
printf( "\t%s\n", $db_name );
}
}
print("\n");
print( "If these are really properly gone, "
. "please remove the corresponding\n"
. "entries from the 'db' table of the production database.\n" );
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment