From f53d4eacd120cdcc4d64bcc06ac3a72f8277a1f4 Mon Sep 17 00:00:00 2001 From: "mkanat%kerio.com" <> Date: Wed, 9 Mar 2005 13:45:34 +0000 Subject: Bug 284348: Move initial table creation into the Bugzilla::DB modules Patch By Max Kanat-Alexander r=glob, r=Tomas.Kopal, a=justdave --- Bugzilla/DB/Mysql.pm | 36 ++++++++++++++++++++++++++++++++++++ Bugzilla/DB/Pg.pm | 3 ++- 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'Bugzilla/DB') diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm index 76cd0966d..14230b188 100644 --- a/Bugzilla/DB/Mysql.pm +++ b/Bugzilla/DB/Mysql.pm @@ -49,6 +49,7 @@ use base qw(Bugzilla::DB); use constant REQUIRED_VERSION => '3.23.41'; use constant PROGRAM_NAME => 'MySQL'; +use constant MODULE_NAME => 'Mysql'; sub new { my ($class, $user, $pass, $host, $dbname, $port, $sock) = @_; @@ -189,4 +190,39 @@ sub bz_rollback_transaction { die("Attempt to rollback transaction on DB without transaction support"); } +##################################################################### +# Database Setup +##################################################################### + +sub bz_setup_database { + my ($self) = @_; + + # Figure out if any existing tables are of type ISAM and convert them + # to type MyISAM if so. ISAM tables are deprecated in MySQL 3.23, + # which Bugzilla now requires, and they don't support more than 16 + # indexes per table, which Bugzilla needs. + my $sth = $self->prepare("SHOW TABLE STATUS"); + $sth->execute; + my @isam_tables = (); + while (my ($name, $type) = $sth->fetchrow_array) { + push(@isam_tables, $name) if $type eq "ISAM"; + } + + if(scalar(@isam_tables)) { + print "One or more of the tables in your existing MySQL database are\n" + . "of type ISAM. ISAM tables are deprecated in MySQL 3.23 and\n" + . "don't support more than 16 indexes per table, which \n" + . "Bugzilla needs.\n Converting your ISAM tables to type" + . " MyISAM:\n\n"; + foreach my $table (@isam_tables) { + print "Converting table $table... "; + $self->do("ALTER TABLE $table TYPE = MYISAM"); + print "done.\n"; + } + print "\nISAM->MyISAM table conversion done.\n\n"; + } + + $self->SUPER::bz_setup_database(); +} + 1; diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm index 5963f5308..2ec3000d5 100644 --- a/Bugzilla/DB/Pg.pm +++ b/Bugzilla/DB/Pg.pm @@ -47,8 +47,9 @@ use Carp; # This module extends the DB interface via inheritance use base qw(Bugzilla::DB); -use constant REQUIRED_VERSION => '7.02.0000'; +use constant REQUIRED_VERSION => '7.03.0000'; use constant PROGRAM_NAME => 'PostgreSQL'; +use constant MODULE_NAME => 'Pg'; sub new { my ($class, $user, $pass, $host, $dbname, $port) = @_; -- cgit v1.2.3-24-g4f1b