head	1.4;
access;
symbols
	TIGRIS_1_1_0RC2:1.3.6.1
	TIGRIS_1_1_0RC1:1.3.6.1
	TIGRIS_1_1:1.3.6.1.0.2
	TIGRIS_1_0_8:1.3.6.1
	TIGRIS_1_0_8RC3:1.3.6.1
	TIGRIS_1_0_8RC2:1.3.6.1
	TIGRIS_1_0_8RC1:1.3.6.1
	TIGRIS_1_0_7:1.3.6.1
	TIGRIS_1_0_7RC3:1.3.6.1
	TIGRIS_1_0_7RC2:1.3.6.1
	TIGRIS_1_0_7RC1:1.3.6.1
	TIGRIS_1_0_6:1.3.6.1
	TIGRIS_1_0_6RC5:1.3.6.1
	TIGRIS_1_0_6RC4:1.3
	TIGRIS_1_0_6RC3:1.3
	TIGRIS_1_0_6RC2:1.3
	TIGRIS_1_0_6RC1:1.3
	TIGRIS_1_0_5:1.3
	TIGRIS_1_0_5RC6:1.3
	TIGRIS_1_0_5RC5:1.3
	TIGRIS_1_0_5RC4:1.3
	TIGRIS_1_0_5RC3:1.3
	TIGRIS_1_0_5RC2:1.3
	TIGRIS_1_0_5RC1:1.3
	TIGRIS_1_0_4:1.3
	TIGRIS_1_0_3:1.3
	TIGRIS_1_0_2:1.3
	TIGRIS_1_0_1:1.3
	TIGRIS_1_0:1.3.0.6
	TIGRIS_1_0_0:1.3
	TIGRIS_1_0_0_RC1:1.3.0.2;
locks; strict;
comment	@# @;


1.4
date	2001.06.13.21.57.07;	author kmaples;	state Exp;
branches;
next	1.3;

1.3
date	2001.03.23.21.42.20;	author kmaples;	state Exp;
branches
	1.3.6.1;
next	1.2;

1.2
date	2001.03.23.01.21.13;	author kmaples;	state Exp;
branches;
next	1.1;

1.1
date	2001.03.23.01.04.15;	author kmaples;	state Exp;
branches;
next	;

1.3.6.1
date	2001.06.13.22.02.05;	author kmaples;	state Exp;
branches;
next	;


desc
@@


1.4
log
@Swapped cmd-line switches for posix-style args.
@
text
@#!/usr/bin/perl
# $Id:  
# Script to upgrade all of the issues dbs associated with the 
# current user

use DBI;

# Stuff grabbed from env.sh:

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};
my $MULTIDB = $ENV{IZ_MULTIPLE_PROJECT_DATABASES};
my $SQL_SCPT = "$SBX/helm/scripts/migration/0.9.2-1.0.0/TIGRIS_1_0_0.issuezilla.sql";

# 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);
}

my $statement = qq{ SHOW DATABASES };

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

if($MULTIDB eq 'true'){
    print "Checking for previous $DBPFX" . "_[0-9] dbs to upgrade:\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 upgrade:\n";
    push(@@dbs, $DBPFX);
}

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

foreach(@@dbs){
    print "  Upgrading $_ \n";
    system("mysql -u$DBUSR -p$DBPW $_ < $SQL_SCPT");
}

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

# 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")){
    if($MULTIDB eq 'true'){
        print "  Deleting old issues directories\n";
        system("rm -rf issues*");  
    } else {
        print "  Deleting old files in data/\n";
        system("rm ./*");
    }
}
if(chdir("$SBX/issuezilla/shadow")){
    print "  Deleting old files from shadow/\n";
    system("rm -rf ./*");
}

if(chdir("$SBX/issuezilla")){
    print "Running checksetup against existing databases...\n";
    print "This may take several minutes\n";
    foreach(@@dbs){
        system("./checksetup.pl --user $DBUSR --password $DBPW --database $_ ");
    }
}
















@


1.3
log
@Tweaking IZ upgrade info
@
text
@d83 1
a83 1
        system("./checksetup.pl -u$DBUSR -p$DBPW -d $_ ");
@


1.3.6.1
log
@Reviewed by:  leonardr@@collab.net
Swapped cmd-line args for posix-style args.
@
text
@d83 1
a83 1
        system("./checksetup.pl --user $DBUSR --password $DBPW --database $_ ");
@


1.2
log
@Added call to checksetup.pl to do schema testing
@
text
@d17 1
a17 1
my $SQL_SCPT = '__SANDBOX__/helm/scripts/migration/0.9.2-1.0.0/TIGRIS_1_0_0.issuezilla.sql';
d60 1
a60 1
print "Finished dropping old issues dbs.\n";
d70 1
d75 1
@


1.1
log
@Adding IZ upgrade scripts.  These superceede those scripts which had been in
issuezilla/patches/
@
text
@d77 23
@

