head	1.9;
access;
symbols
	TIGRIS_1_1_0RC2:1.7
	TIGRIS_1_1_0RC1:1.7
	TIGRIS_1_1:1.7.0.4
	TIGRIS_1_0_8:1.7
	TIGRIS_1_0_8RC3:1.7
	TIGRIS_1_0_8RC2:1.7
	TIGRIS_1_0_8RC1:1.7
	TIGRIS_1_0_7:1.7
	TIGRIS_1_0_7RC3:1.7
	TIGRIS_1_0_7RC2:1.7
	TIGRIS_1_0_7RC1:1.7
	TIGRIS_1_0_6:1.7
	TIGRIS_1_0_6RC5:1.7
	TIGRIS_1_0_6RC4:1.7
	TIGRIS_1_0_6RC3:1.7
	TIGRIS_1_0_6RC2:1.7
	TIGRIS_1_0_6RC1:1.7
	TIGRIS_1_0_5:1.7
	TIGRIS_1_0_5RC6:1.7
	TIGRIS_1_0_5RC5:1.7
	TIGRIS_1_0_5RC4:1.7
	TIGRIS_1_0_5RC3:1.7
	TIGRIS_1_0_5RC2:1.7
	TIGRIS_1_0_5RC1:1.7
	TIGRIS_1_0_4:1.7
	TIGRIS_1_0_3:1.7
	TIGRIS_1_0_2:1.7
	TIGRIS_1_0_1:1.7
	TIGRIS_1_0:1.7.0.6
	TIGRIS_1_0_0:1.7
	TIGRIS_1_0_0_RC1:1.7.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.4
	TIGRIS_0_9_2_3:1.4
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.4
	TIGRIS_0_9_2_1:1.4
	TIGRIS_0_9_2:1.4.0.2
	TIGRIS_0_9_0:1.3.0.2
	TIGRIS_0_8_4:1.2.0.2;
locks; strict;
comment	@# @;


1.9
date	2001.04.17.06.44.27;	author dlr;	state Exp;
branches;
next	1.8;

1.8
date	2001.04.17.06.43.26;	author dlr;	state Exp;
branches;
next	1.7;

1.7
date	2001.02.21.01.56.41;	author edk;	state Exp;
branches;
next	1.6;

1.6
date	2001.02.21.01.08.28;	author dlr;	state Exp;
branches;
next	1.5;

1.5
date	2001.01.31.17.32.38;	author kmaples;	state Exp;
branches;
next	1.4;

1.4
date	2001.01.03.02.32.59;	author kmaples;	state Exp;
branches
	1.4.4.1;
next	1.3;

1.3
date	2000.12.15.22.13.02;	author kmaples;	state Exp;
branches;
next	1.2;

1.2
date	2000.11.17.17.54.13;	author kmaples;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2000.11.17.00.37.43;	author kmaples;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2001.02.21.00.36.25;	author dlr;	state Exp;
branches;
next	;

1.2.2.1
date	2000.12.15.22.58.42;	author kmaples;	state Exp;
branches;
next	;

1.4.4.1
date	2001.02.20.04.41.59;	author dlr;	state Exp;
branches;
next	1.4.4.2;

1.4.4.2
date	2001.02.20.04.50.18;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.9
log
@* Added -w.

* Added some badly needed whitespace.
@
text
@#!/usr/bin/perl -w
# $Id: remove_old_issue_dbs,v 1.8 2001/04/17 06:43:26 dlr Exp $ 
# Script to drop all of the issues dbs associated with the 
# current user

use DBI;

BEGIN
{
    unshift(@@INC, "$ENV{SANDBOX}/scripts");
}
use HelmDB;

my $DBPFX   = $ENV{IZ_DATABASE_NAME};
my $SBX     = $ENV{SANDBOX};
my $MULTIDB = $ENV{IZ_MULTIPLE_PROJECT_DATABASES};

my $CONN = HelmDB::connect('mysql', $ENV{DATABASE_ADMIN_USER},
                           $ENV{DATABASE_ADMIN_PASSWORD});

my $statement = qq{ SHOW DATABASES };

my $select;
my $ret;
my @@dbs;

if ($MULTIDB eq 'true') {
    print "Checking for previous $DBPFX", "_[0-9] dbs to drop:\n";
    
    $select = $CONN->prepare($statement);
    $ret    = $select->execute;

    while (my (@@record) = $select->fetchrow_array) {
        push(@@dbs,$record[0]) if $record[0] =~ m/^($DBPFX)_[\d]+$/;
    }
}
else {
    print "Checking for previous $DBPFX db to drop:\n";
    push(@@dbs, $DBPFX);
}

foreach (@@dbs) {
    print "  Dropping  $_ \n";
    $statement = qq{ DROP DATABASE IF EXISTS $_ };
    $ret = $CONN->do($statement);
    print "$ret rows affected\n";
}

print "Finished dropping old issues dbs.\n";

$select->finish() if $select;
$CONN->disconnect;

# Since IZ creates directories to hold parameters and whatnot 
# for the current project, we need to delete the files which
# were associated with the old project: 
if (chdir("$SBX/issuezilla/data")) {
    print "  Deleting old issues directories\n";
    system("rm -rf issues*");  
}
@


1.8
log
@Refactored to make use of HelmDB.
@
text
@d1 2
a2 2
#!/usr/bin/perl
# $Id: remove_old_issue_dbs,v 1.7 2001/02/21 01:56:41 edk Exp $ 
d33 1
a33 1
    while(my (@@record) = $select->fetchrow_array){
d42 1
a42 1
foreach(@@dbs){
@


1.7
log
@add new files from the branch to the head (there should be only added
files, ie. no modified files).
@
text
@d2 1
a2 1
# $Id: remove_old_issue_dbs,v 1.1.1.1 2001/02/21 00:36:25 dlr Exp $ 
d8 5
a12 1
# Stuff grabbed from env.sh:
d14 2
a15 6
my $DBPFX = $ENV{IZ_DATABASE_NAME};
my $DBPW  = $ENV{DATABASE_ADMIN_PASSWORD};
my $DBUSR = $ENV{DATABASE_ADMIN_USER};
my $DBHOST= $ENV{DATABASE_HOST};
my $DBPORT= $ENV{DATABASE_PORT};
my $SBX   = $ENV{SANDBOX};
d18 2
a19 12
# The database to connect to should probably be something
# other than 'mysql' - but since we're talking about the 
# database as a whole, this shouldn't matter:

my $dbc  = join(':','DBI','mysql','mysql',$DBHOST, $DBPORT);
my $CONN = DBI->connect($dbc, $DBUSR, $DBPW);

# Check for a good connection:
unless( $CONN =~ m/HASH/){
    print "No connection to database: $!\n";
    exit(1);
}
d27 2
a28 2
if($MULTIDB eq 'true'){
    print "Checking for previous $DBPFX" . "_[0-9] dbs to drop:\n";
d36 2
a37 1
} else {
d57 1
a57 1
if(chdir("$SBX/issuezilla/data")){
a60 2


@


1.6
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d2 1
a2 1
# $Id: remove_old_issue_dbs,v 1.4.4.2 2001/02/20 04:50:18 dlr Exp $ 
@


1.5
log
@Changed to honor DATABASE_HOST
@
text
@d2 1
a2 1
# $Id: remove_old_issue_dbs,v 1.4 2001/01/03 02:32:59 kmaples Exp $ 
@


1.4
log
@Changed deletion to match the setting of IZ_MULTIPLE_PROJECT_DATABASES, since
you ought to be deleting the same kind of database you're creating.  This
mostly impacts deletions when IZ_MULTIPLE_PROJECT_DATABASES is 'false'.
@
text
@d2 1
a2 1
# $Id: remove_old_issue_dbs,v 1.3 2000/12/15 22:13:02 kmaples Exp $ 
d13 2
d18 5
a22 1
my $dbc = "DBI:mysql:";
d24 6
@


1.4.4.1
log
@Merging in changes from the HEAD.
@
text
@d2 1
a2 1
# $Id: remove_old_issue_dbs,v 1.4 2001/01/03 02:32:59 kmaples Exp $ 
a12 2
my $DBHOST= $ENV{DATABASE_HOST};
my $DBPORT= $ENV{DATABASE_PORT};
d16 1
a16 13
# The database to connect to should probably be something
# other than 'mysql' - but since we're talking about the 
# database as a whole, this shouldn't matter:

my $dbc  = join(':','DBI','mysql','mysql',$DBHOST, $DBPORT);
my $CONN = DBI->connect($dbc, $DBUSR, $DBPW);

# Check for a good connection:
unless( $CONN =~ m/HASH/){
    print "No connection to database: $!\n";
    exit(1);
}

@


1.4.4.2
log
@Corrected mismerge.
@
text
@d2 1
a2 1
# $Id: remove_old_issue_dbs,v 1.4.4.1 2001/02/20 04:41:59 dlr Exp $ 
d30 2
@


1.3
log
@Delete IZ records of projects from the file system as long as you're deleting
the database.  This will prevent subsequently created projects from inheriting
data and parameters from the previous projects.
@
text
@d2 1
a2 1
# $Id: remove_old_issue_dbs,v 1.2 2000/11/17 17:54:13 kmaples Exp $ 
d14 1
d21 3
a23 1
print "Checking for previous $DBPFX" . "_[0-9] dbs to drop:\n";
d25 12
a36 6
my $select = $CONN->prepare($statement);
my $ret    = $select->execute;
my @@dbs;
	
while(my (@@record) = $select->fetchrow_array){
    push(@@dbs,$record[0]) if $record[0] =~ m/^($DBPFX)_[\d]+$/;
d41 1
a41 1
    $statement = qq{ DROP DATABASE $_ };
d48 1
a48 1
$select->finish();
@


1.2
log
@Added some comments and explanations.
@
text
@d2 1
a2 1
# $Id: $ 
d13 1
a13 1

d41 8
@


1.2.2.1
log
@Importing into branch: this is to remove old IZ parameter files when the
dbs are dropped.
@
text
@d2 1
a2 1
# $Id: remove_old_issue_dbs,v 1.3 2000/12/15 22:13:02 kmaples Exp $ 
d13 1
a13 1
my $SBX   = $ENV{SANDBOX};
a40 8

# Since IZ creates directories to hold parameters and whatnot 
# for the current project, we need to delete the files which
# were associated with the old project: 
if(chdir("$SBX/issuezilla/data")){
    print "  Deleting old issues directories\n";
    system("rm -rf issues*");  
}
@


1.1
log
@First checkin of some rudimentary scripts to perform actions on issuezilla
complimentary to actions performed by populate_repository and create_tigris_database
@
text
@d2 3
d8 2
d20 2
d31 1
a31 1
    print "Dropping  $_ \n";
d36 2
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@a1 3
# $Id: remove_old_issue_dbs,v 1.4.4.2 2001/02/20 04:50:18 dlr Exp $ 
# Script to drop all of the issues dbs associated with the 
# current user
a4 2
# Stuff grabbed from env.sh:

a7 8
my $DBHOST= $ENV{DATABASE_HOST};
my $DBPORT= $ENV{DATABASE_PORT};
my $SBX   = $ENV{SANDBOX};
my $MULTIDB = $ENV{IZ_MULTIPLE_PROJECT_DATABASES};

# The database to connect to should probably be something
# other than 'mysql' - but since we're talking about the 
# database as a whole, this shouldn't matter:
d9 2
a10 1
my $dbc  = join(':','DBI','mysql','mysql',$DBHOST, $DBPORT);
a12 6
# Check for a good connection:
unless( $CONN =~ m/HASH/){
    print "No connection to database: $!\n";
    exit(1);
}

d15 2
a16 2
my $select;
my $ret;
d18 3
a20 13

if($MULTIDB eq 'true'){
    print "Checking for previous $DBPFX" . "_[0-9] dbs to drop:\n";
    
    $select = $CONN->prepare($statement);
    $ret    = $select->execute;

    while(my (@@record) = $select->fetchrow_array){
        push(@@dbs,$record[0]) if $record[0] =~ m/^($DBPFX)_[\d]+$/;
    }
} else {
    print "Checking for previous $DBPFX db to drop:\n";
    push(@@dbs, $DBPFX);
d24 2
a25 2
    print "  Dropping  $_ \n";
    $statement = qq{ DROP DATABASE IF EXISTS $_ };
d30 1
a30 3
print "Finished dropping old issues dbs.\n";

$select->finish() if $select;
a31 8

# Since IZ creates directories to hold parameters and whatnot 
# for the current project, we need to delete the files which
# were associated with the old project: 
if(chdir("$SBX/issuezilla/data")){
    print "  Deleting old issues directories\n";
    system("rm -rf issues*");  
}
@


