[Rt-commit] r12311 - in rt/branches/3.8-TESTING: .
ruz at bestpractical.com
ruz at bestpractical.com
Wed May 14 12:13:33 EDT 2008
Author: ruz
Date: Wed May 14 12:13:30 2008
New Revision: 12311
Modified:
rt/branches/3.8-TESTING/ (props changed)
rt/branches/3.8-TESTING/sbin/rt-setup-database.in
Log:
r12347 at cubic-pc: cubic | 2008-05-14 16:09:40 +0400
* db compatibility checks have been moved into handle
Modified: rt/branches/3.8-TESTING/sbin/rt-setup-database.in
==============================================================================
--- rt/branches/3.8-TESTING/sbin/rt-setup-database.in (original)
+++ rt/branches/3.8-TESTING/sbin/rt-setup-database.in Wed May 14 12:13:30 2008
@@ -98,7 +98,7 @@
# check and setup @actions
my @actions = grep $_, split /,/, $args{'action'};
if ( @actions > 1 && $args{'datafile'} ) {
- print STDERR "You can not use --datafile option with init or multiple actions.\n";
+ print STDERR "You can not use --datafile option with multiple actions.\n";
exit(-1);
}
foreach ( @actions ) {
@@ -156,6 +156,9 @@
my ($status, $msg) = (1, '');
if ( $action eq 'create' ) {
my $dbh = get_system_dbh();
+ ($status, $msg) = RT::Handle->CheckCompatibility( $dbh, 'pre' );
+ error($action, $msg) unless $status;
+
print "Now creating a $db_type database $db_name for RT.\n";
($status, $msg) = RT::Handle->CreateDatabase( $dbh );
}
@@ -187,14 +190,16 @@
}
elsif ( $action eq 'schema' ) {
my $dbh = get_admin_dbh();
- check_db_compatibility( $dbh );
+ ($status, $msg) = RT::Handle->CheckCompatibility( $dbh, 'pre' );
+ error($action, $msg) unless $status;
print "Now populating database schema.\n";
($status, $msg) = RT::Handle->InsertSchema( $dbh, $args{'datafile'} || $args{'datadir'} );
}
elsif ( $action eq 'acl' ) {
my $dbh = get_admin_dbh();
- check_db_compatibility( $dbh );
+ ($status, $msg) = RT::Handle->CheckCompatibility( $dbh, 'pre' );
+ error($action, $msg) unless $status;
print "Now inserting database ACLs\n";
($status, $msg) = RT::Handle->InsertACL( $dbh, $args{'datafile'} || $args{'datadir'} );
@@ -204,7 +209,8 @@
$RT::Handle->dbh( undef );
RT::ConnectToDatabase();
RT::InitLogging();
- check_db_compatibility( $RT::Handle->dbh );
+ ($status, $msg) = RT::Handle->CheckCompatibility( $RT::Handle->dbh, 'post' );
+ error($action, $msg) unless $status;
print "Now inserting RT core system objects\n";
($status, $msg) = $RT::Handle->InsertInitialData;
@@ -212,7 +218,8 @@
elsif ( $action eq 'insert' ) {
$RT::Handle = new RT::Handle;
RT::Init();
- check_db_compatibility( $RT::Handle->dbh );
+ ($status, $msg) = RT::Handle->CheckCompatibility( $RT::Handle->dbh, 'post' );
+ error($action, $msg) unless $status;
print "Now inserting data\n";
my $file = $args{'datafile'};
@@ -220,66 +227,15 @@
$file ||= $args{'datadir'}."/content";
($status, $msg) = $RT::Handle->InsertData( $file );
}
- unless ( $status ) {
- print STDERR "Couldn't finish '$action' step.\n\n";
- print STDERR "ERROR: $msg\n\n";
- exit(-1);
- }
+ error($action, $msg) unless $status;
print "Done.\n";
}
-sub check_db_compatibility {
- my $dbh = shift;
- if ( lc $db_type eq "mysql" ) {
- # Check which version we're running
- my $version = ($dbh->selectrow_array("show variables like 'version'"))[1];
- unless ( $version ) {
- print STDERR "Couldn't get version of the mysql server\n";
- exit -1;
- }
-
- ($version) = $version =~ /^(\d+\.\d+)/;
- if ( $version < 4 ) {
- print STDERR "RT is unsupported on MySQL versions before 4.0.x, it's $version\n";
- exit -1;
- }
-
- # MySQL must have InnoDB support
- if ( $args{'action'} =~ /^(init|insert|schema)$/ ) {
- print "Checking that mysql has spport for InnoDB.\n" if $args{'debug'};
- my $innodb = ($dbh->selectrow_array("show variables like 'have_innodb'"))[1];
- if ( lc $innodb eq "no" ) {
- print STDERR "RT requires that MySQL be compiled with InnoDB table support.\n".
- "See http://dev.mysql.com/doc/mysql/en/InnoDB.html\n";
- exit -1;
- } elsif ( lc $innodb eq "disabled" ) {
- print STDERR "RT requires that MySQL InnoDB table support be enabled.\n".
- ($version < 4
- ? "Add 'innodb_data_file_path=ibdata1:10M:autoextend' to the [mysqld] section of my.cnf\n"
- : "Remove the 'skip-innodb' line from your my.cnf file, restart MySQL, and try again.\n");
- exit -1;
- }
- }
-
- if ( $args{'action'} =~ /^(insert)$/ ) {
- print "Checking that Tickets table is of InnoDB type.\n" if $args{'debug'};
- my $create_table = $dbh->selectrow_arrayref("SHOW CREATE TABLE Tickets")->[1];
- unless ( $create_table =~ /(?:ENGINE|TYPE)=InnoDB/i ) {
- print STDERR "RT requires that all its tables be of InnoDB type.\n".
- "Upgrade RT tables.\n";
- exit -1;
- }
- }
- if ( $version >= 4.1 && $args{'action'} =~ /^(insert|schema)$/ ) {
- print "MySQL >= 4.1, checking that user upgraded.\n" if $args{'debug'};
- my $create_table = $dbh->selectrow_arrayref("SHOW CREATE TABLE Attachments")->[1];
- unless ( $create_table =~ /\bContent\b[^,]*BLOB/i ) {
- print STDERR "*** WARNING: RT since version 3.8 has new schema for MySQL versions after 4.1.0\n"
- ."Follow instructions in the UPGRADING.mysql file.\n";
- sleep 3;
- }
- }
- }
+sub error {
+ my ($action, $msg) = @_;
+ print STDERR "Couldn't finish '$action' step.\n\n";
+ print STDERR "ERROR: $msg\n\n";
+ exit(-1);
}
sub get_dba_password {
More information about the Rt-commit
mailing list