[Rt-commit] r7192 - rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT
ruz at bestpractical.com
ruz at bestpractical.com
Wed Mar 7 20:58:06 EST 2007
Author: ruz
Date: Wed Mar 7 20:58:06 2007
New Revision: 7192
Modified:
rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Handle.pm
Log:
* rename {create,drop}_db to CamelCase
* make DBI handle a mandatory argument as $self->dbh is really not
suitable for these operations and to avoid any chance people
use it we make argument required
* update docs
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Handle.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Handle.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Handle.pm Wed Mar 7 20:58:06 2007
@@ -138,15 +138,23 @@
}
-# dealing with intial data
+=head2 Database maintanance
-=head2
+=head2 CreateDatabase $DBH
+
+Creates a new database. This method can be used as class method.
+
+Takes DBI handle. Many database systems require special handle to
+allow you to create a new database, so you have to use L<SystemDSN>
+method during connection.
+
+Fetches type and name of the DB from the config.
=cut
-sub create_db {
+sub CreateDatabase {
my $self = shift;
- my $dbh = shift || $self->dbh;
+ my $dbh = shift || die "No DBI handle provided";
my $db_type = RT->Config->Get('DatabaseType');
my $db_name = RT->Config->Get('DatabaseName');
print "Creating $db_type database $db_name.\n";
@@ -168,17 +176,30 @@
}
}
-=head2 drop_db
+=head3 DropDatabase $DBH [Force => 0]
+
+Drops RT's database. This method can be used as class method.
+
+Takes DBI handle as first argument. Many database systems require
+special handle to allow you to create a new database, so you have
+to use L<SystemDSN> method during connection.
+
+Takes as well optional named argument C<Force>, if it's true than
+no questions would be asked.
+
+Fetches type and name of the DB from the config.
=cut
-sub drop_db {
+sub DropDatabase {
my $self = shift;
- my $dbh = shift || $self->dbh;
- my %args = %{ shift || {}};
+ my $dbh = shift || die "No DBI handle provided";
+ my %args = ( Force => 0, @_ );
+
my $db_type = RT->Config->Get('DatabaseType');
my $db_name = RT->Config->Get('DatabaseName');
my $db_host = RT->Config->Get('DatabaseHost');
+
if ( $db_type eq 'Oracle' ) {
print <<END;
@@ -200,7 +221,7 @@
}
- print "Dropping ". $db_type ." database ". $db_name .".\n";
+ print "Dropping $db_type database $db_name.\n";
if ( $db_type eq 'SQLite' ) {
unlink $RT::VarPath.'/'.$db_name or warn $!;
More information about the Rt-commit
mailing list