head	1.3;
access;
symbols
	TIGRIS_1_1_0RC2:1.3
	TIGRIS_1_1_0RC1:1.3
	TIGRIS_1_1:1.3.0.4
	TIGRIS_1_0_8:1.3
	TIGRIS_1_0_8RC3:1.3
	TIGRIS_1_0_8RC2:1.3
	TIGRIS_1_0_8RC1:1.3
	TIGRIS_1_0_7:1.3
	TIGRIS_1_0_7RC3:1.3
	TIGRIS_1_0_7RC2:1.3
	TIGRIS_1_0_7RC1:1.3
	TIGRIS_1_0_6:1.3
	TIGRIS_1_0_6RC5:1.3
	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.3
date	2001.03.21.02.15.58;	author leonardr;	state Exp;
branches;
next	1.2;

1.2
date	2001.03.21.01.24.56;	author leonardr;	state Exp;
branches;
next	1.1;

1.1
date	2001.03.21.00.39.25;	author leonardr;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Changed description.
@
text
@#!/usr/bin/perl -w
# -*- Perl -*- script which will delete the Helm test users from the database.
#
# $Id: deleteTestUsers.pl,v 1.2 2001/03/21 01:24:56 leonardr Exp $

use DBI;
use strict;

my $dbh = dbConnection($ENV{DATABASE_NAME}, $ENV{DATABASE_ADMIN_USER},
                         $ENV{DATABASE_ADMIN_PASSWORD});

foreach my $loginID (('q', 'testreguser', 'testobserver', 'testdev', 'testcontdev', 'testowner', 'testdomadmin', 'testhostadmin'))
{
  deleteUser($dbh, $loginID);
}

$dbh->disconnect();

sub deleteUser()
{
    my ($dbh, $loginID) = (@@_);
    print "Deleting user $loginID\n";

  my $getUserIDQuery = "select userID from User where loginID='$loginID'";
  my $something = runSelect($dbh, $getUserIDQuery);
  my $userID = "";
  $userID = $something->{userID};
  if (defined($userID))
  {
      my $urpQuery = "delete from HELM_USER_ROLE_PROJECT where USER_ID = '$userID'";
      my $userQuery = "delete from User where userID = '$userID'";
      runStatement($dbh, $urpQuery);
      runStatement($dbh, $userQuery);
  }
}

####################################################################

# Creates and returns a handle to the database (i.e. connection reference).
#
# ex. my $conn = dbConnection('tigris', 'user', 'passwd');
sub dbConnection($$$)
{
    my ($dbName, $dbUser, $dbPasswd) = @@_;
    return DBI->connect
        ("DBI:mysql:$dbName:$ENV{DATABASE_HOST}:$ENV{DATABASE_PORT}",
         $dbUser, $dbPasswd,
        { RaiseError => 1, AutoCommit => 1 });
}

# Runs a SQL statement.
#
# ex. my $rv = runStatement($dbh, 'delete from bar where baz');
sub runStatement($$)
{
    my ($dbh, $sql) = @@_;
    #print "sql=$sql\n";  # debug
    $sql =~ s/(.*)\;\s*$/$1/s;
    my $sth = $dbh->prepare($sql);
    my $rv = $sth->execute();
    $sth->finish();
    return $rv;
}

# Runs a SQL SELECT statement.
#
# ex. my $rv = runSelect($dbh, 'select foo from bar where baz');
sub runSelect($$)
{
  my ($dbh, $sql) = @@_;
  #print "sql=$sql\n";  # debug
  $sql =~ s/(.*)\;\s*$/$1/s;
  my $sth = $dbh->prepare($sql);

  my $rv = $sth->execute();
  my $hashref=$sth->fetchrow_hashref();
  $sth->finish();
  return $hashref;
}


@


1.2
log
@Got rid of my sandbox information.
@
text
@d2 1
a2 1
# -*- Perl -*- script which will delete a user from the database.
d4 1
a4 1
# $Id: deleteTestUsers.pl,v 1.1 2001/03/21 00:39:25 leonardr Exp $
a7 3

# Function prototypes for Perl 6.
sub bootstrap();
@


1.1
log
@Added data migration scripts.
@
text
@d4 1
a4 1
# $Id: create_tigris_database,v 1.12 2001/02/23 05:11:37 dlr Exp $
d12 1
a12 1
my $dbh = dbConnection('tigris_1079', $ENV{DATABASE_ADMIN_USER},
@

