--- db/prgsrc/mkdb.pl 2001/10/14 17:48:12 1.11 +++ db/prgsrc/mkdb.pl 2009/12/12 16:55:21 1.24 @@ -23,7 +23,7 @@ The database, user and password are hard Dmitry Rubinstein -=head1 $Id: mkdb.pl,v 1.11 2001/10/14 17:48:12 boris Exp $ +=head1 $Id: mkdb.pl,v 1.24 2009/12/12 16:55:21 roma7 Exp $ =cut @@ -37,7 +37,7 @@ sub CheckTable my ($TabName) = @_; my ($ans); - if (scalar(grep(/^$TabName$/, @tbl_list))) { + if (scalar(grep(/^$TabName$/i, @tbl_list))) { print "Table $TabName exists. Do you want to delete it? "; $ans = ; if ($ans =~ /[yY]/) { @@ -56,8 +56,8 @@ print "Before connecting to the DB\n"; $dbh = DBI->connect("DBI:mysql:chgk", "piataev", "") or die "Can't connect to DB chgk\n" . $dbh->errstr; print "Connected successfully\n"; - - @tbl_list = $dbh->func( '_ListTables' ); +if ($dbh->get_info( 18 )=~/^(5|(4.1))/) {$dbh->do("SET NAMES 'koi8r'");} + @tbl_list = $dbh->tables(); &CheckTable("Questions"); $dbh->do("CREATE TABLE Questions ( @@ -67,15 +67,20 @@ print "Connected successfully\n"; KEY ParentIdKey (ParentId), Number SMALLINT UNSIGNED NOT NULL, KEY NumberKey (Number), - Type TEXT NOT NULL, + `Type` CHAR(5) NOT NULL DEFAULT 'þ', + KEY TypeKey (Type), Question TEXT, Answer TEXT, + PassCriteria TEXT, Authors TEXT, Sources TEXT, Comments TEXT, Rating TEXT, + Topic TEXT, ProcessedBySearch INT - )") + ) TYPE=MyISAM" + . (($dbh->get_info( 18 )=~/^(5|(4.1))/)?' DEFAULT CHARSET=koi8r':'') +) or die "Can't create Questions table: $!\n"; &CheckTable("Tournaments"); @@ -96,8 +101,13 @@ print "Connected successfully\n"; Editors TEXT, EnteredBy TEXT, PlayedAt DATE, + PlayedAt2 DATE, + KandId INT, CreatedAt DATE NOT NULL - )") + ) TYPE=MyISAM" + . (($dbh->get_info( 18 )=~/^(5|(4.1))/)?' DEFAULT CHARSET=koi8r':'') + +) or die "Can't create Tournaments table: $!\n"; # CREATE INDEX ParentInd ON Tournaments (ParentId)