Diff for /db/prgsrc/mkdb.pl between versions 1.1 and 1.24

version 1.1, 2000/10/16 23:20:49 version 1.24, 2009/12/12 16:55:21
Line 4 Line 4
   
 mkdb.pl - a script for creation of new database.   mkdb.pl - a script for creation of new database. 
   
   =head1 SYNOPSIS
   
   mkdb.pl
   
   
 =head1 DESCRIPTION  =head1 DESCRIPTION
   
 This script will create tables Questions and Tournaments  This script will create tables Questions and Tournaments
Line 32  sub CheckTable Line 37  sub CheckTable
         my ($TabName) = @_;          my ($TabName) = @_;
         my ($ans);          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? ";                  print "Table $TabName exists. Do you want to delete it? ";
                 $ans = <STDIN>;                  $ans = <STDIN>;
                 if ($ans =~ /[yY]/) {                  if ($ans =~ /[yY]/) {
Line 51  print "Before connecting to the DB\n"; Line 56  print "Before connecting to the DB\n";
         $dbh = DBI->connect("DBI:mysql:chgk", "piataev", "")          $dbh = DBI->connect("DBI:mysql:chgk", "piataev", "")
                 or die "Can't connect to DB chgk\n" . $dbh->errstr;                  or die "Can't connect to DB chgk\n" . $dbh->errstr;
 print "Connected successfully\n";  print "Connected successfully\n";
   if ($dbh->get_info( 18 )=~/^(5|(4.1))/)  {$dbh->do("SET NAMES 'koi8r'");}
         @tbl_list = $dbh->func( '_ListTables' );          @tbl_list = $dbh->tables();
   
         &CheckTable("Questions");          &CheckTable("Questions");
         $dbh->do("CREATE TABLE Questions (          $dbh->do("CREATE TABLE Questions (
Line 60  print "Connected successfully\n"; Line 65  print "Connected successfully\n";
                         KEY QuestionIdKey (QuestionId),                          KEY QuestionIdKey (QuestionId),
                 ParentId        SMALLINT UNSIGNED NOT NULL,                  ParentId        SMALLINT UNSIGNED NOT NULL,
                         KEY ParentIdKey (ParentId),                          KEY ParentIdKey (ParentId),
                 Number          TINYINT UNSIGNED NOT NULL,                  Number         SMALLINT UNSIGNED NOT NULL,
                         KEY NumberKey (Number),                          KEY NumberKey (Number),
                 # Currently there are 2 types of questions: 'Chto? Gde? Kogda?'                  `Type`          CHAR(5) NOT NULL DEFAULT 'þ',
                 # and 'Brain ring'.                          KEY TypeKey (Type),
                 Type                    ENUM('þ','â') NOT NULL,  
                 Question        TEXT,                  Question        TEXT,
                 Answer          TINYTEXT,                  Answer          TEXT,
                 Authors                 TINYTEXT,                  PassCriteria    TEXT,
                 Sources                 TINYTEXT,                  Authors         TEXT,
                 Comments        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";          or die "Can't create Questions table: $!\n";
                   
         &CheckTable("Tournaments");          &CheckTable("Tournaments");
Line 81  print "Connected successfully\n"; Line 91  print "Connected successfully\n";
                 ParentId        INT UNSIGNED NOT NULL,                  ParentId        INT UNSIGNED NOT NULL,
                         KEY ParentIdKey (ParentId),                          KEY ParentIdKey (ParentId),
                 Title           TINYTEXT NOT NULL,                  Title           TINYTEXT NOT NULL,
                   Number    SMALLINT UNSIGNED,
                 QuestionsNum INT UNSIGNED DEFAULT 0,                  QuestionsNum INT UNSIGNED DEFAULT 0,
                 Type                    ENUM('ç','ô','þ'),                  Type            ENUM('ç','ô','þ'),
                 MetaId          INT UNSIGNED,  
                 Copyright       TEXT,                  Copyright       TEXT,
                 Info                    TEXT,                  Info                    TEXT,
                 URL                     TINYTEXT,                  URL                     TINYTEXT,
                 FileName        CHAR(25),                  FileName        CHAR(25),
                   Editors         TEXT,
                   EnteredBy       TEXT,
                 PlayedAt        DATE,                  PlayedAt        DATE,
                   PlayedAt2       DATE,           
                   KandId          INT,            
                 CreatedAt       DATE NOT NULL                  CreatedAt       DATE NOT NULL
         )")           ) TYPE=MyISAM"
           . (($dbh->get_info( 18 )=~/^(5|(4.1))/)?' DEFAULT CHARSET=koi8r':'')
   
   ) 
         or die "Can't create Tournaments table: $!\n";          or die "Can't create Tournaments table: $!\n";
   
 #       CREATE INDEX ParentInd ON Tournaments (ParentId)  #       CREATE INDEX ParentInd ON Tournaments (ParentId)

Removed from v.1.1  
changed lines
  Added in v.1.24


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>