[Rt-commit] r7226 - rt/branches/3.7-EXPERIMENTAL-TUNIS/sbin
ruz at bestpractical.com
ruz at bestpractical.com
Tue Mar 13 09:14:18 EDT 2007
Author: ruz
Date: Tue Mar 13 09:14:10 2007
New Revision: 7226
Modified:
rt/branches/3.7-EXPERIMENTAL-TUNIS/sbin/rt-setup-database.in
Log:
* add get_admin_dbh
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/sbin/rt-setup-database.in
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/sbin/rt-setup-database.in (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/sbin/rt-setup-database.in Tue Mar 13 09:14:10 2007
@@ -137,10 +137,9 @@
$RT::Handle ||= new RT::Handle;
-my $dbh;
foreach my $action ( @actions ) {
if ( $action eq 'create' ) {
- $dbh = get_system_dbh();
+ my $dbh = get_system_dbh();
print "Now creating a database for RT.\n";
if ( $db_type ne 'Oracle' || $dba_user ne $db_user ) {
RT::Handle->CreateDatabase( $dbh );
@@ -149,13 +148,13 @@
}
}
elsif ( $action eq 'drop' ) {
- $dbh = get_system_dbh();
+ my $dbh = get_system_dbh();
print "Now dropping RT database\n";
RT::Handle->DropDatabase( $dbh, Force => $args{'force'} );
}
elsif ( $action eq 'schema' ) {
- $dbh = get_rt_dbh( $dba_user, $dba_pass );
+ my $dbh = get_admin_dbh();
check_db_compatibility( $dbh );
$RT::Handle->dbh( $dbh );
@@ -164,16 +163,16 @@
$RT::Handle->insert_schema($dbh, $args{'datadir'});
}
elsif ( $action eq 'acl' ) {
- $dbh = get_rt_dbh( $dba_user, $dba_pass );
+ my $dbh = get_admin_dbh();
check_db_compatibility( $dbh );
$RT::Handle->dbh( $dbh );
print "Now inserting database ACLs\n";
- $RT::Handle->insert_acl($dbh, $args{'datadir'}) # unless $db_type eq 'Oracle'
+ $RT::Handle->InsertACL( $dbh, $args{'datadir'} ) # unless $db_type eq 'Oracle'
}
elsif ( $action eq 'coredata' ) {
- $dbh = get_rt_dbh();
+ my $dbh = get_rt_dbh();
check_db_compatibility( $dbh );
$RT::Handle->dbh( $dbh );
@@ -182,7 +181,7 @@
$RT::Handle->insert_initial_data();
}
elsif ( $action eq 'insert' ) {
- $dbh = get_rt_dbh();
+ my $dbh = get_rt_dbh();
check_db_compatibility( $dbh );
$RT::Handle->dbh( $dbh );
@@ -263,6 +262,10 @@
return _get_dbh( RT::Handle->SystemDSN, $dba_user, $dba_pass );
}
+sub get_admin_dbh {
+ return _get_dbh( RT::Handle->DSN, $dba_user, $dba_pass );
+}
+
=head2 get_rt_dbh [USER, PASSWORD]
Returns L<DBI> database handle connected to RT database,
@@ -272,11 +275,7 @@
=cut
sub get_rt_dbh {
- my ($user, $pass) = @_;
- unless ( @_ ) {
- ($user, $pass) = ($db_user, $db_pass);
- }
- return _get_dbh( RT::Handle->DSN, $user, $pass );
+ return _get_dbh( RT::Handle->DSN, $db_user, $db_pass );
}
sub _get_dbh {
More information about the Rt-commit
mailing list