Add HostStats table to install script.
Signed-off-by: Thomas Hochstein <thh@thh.name>
This commit is contained in:
		
							parent
							
								
									9ccb915d77
								
							
						
					
					
						commit
						713db80545
					
				
					 1 changed files with 23 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -46,7 +46,7 @@ my $DBCreate = <<SQLDB;
 | 
			
		|||
CREATE DATABASE IF NOT EXISTS `$Conf{'DBDatabase'}` DEFAULT CHARSET=utf8;
 | 
			
		||||
SQLDB
 | 
			
		||||
 | 
			
		||||
my %DBCreate = ('DBTableRaw'  => <<RAW, 'DBTableGrps' => <<GRPS);
 | 
			
		||||
my %DBCreate = ('DBTableRaw'  => <<RAW, 'DBTableGrps' => <<GRPS, 'DBTableHosts' => <<HOSTS);
 | 
			
		||||
--
 | 
			
		||||
-- Table structure for table DBTableRaw
 | 
			
		||||
--
 | 
			
		||||
| 
						 | 
				
			
			@ -82,10 +82,26 @@ CREATE TABLE IF NOT EXISTS `$Conf{'DBTableGrps'}` (
 | 
			
		|||
  `revision` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
 | 
			
		||||
  PRIMARY KEY  (`id`),
 | 
			
		||||
  UNIQUE KEY `month_newsgroup` (`month`,`newsgroup`),
 | 
			
		||||
  KEY `newsgroup` (`newsgroup`),
 | 
			
		||||
  KEY `postings` (`postings`)
 | 
			
		||||
  KEY `month` (`month`),
 | 
			
		||||
  KEY `newsgroup` (`newsgroup`)
 | 
			
		||||
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='Postings per newsgroup';
 | 
			
		||||
GRPS
 | 
			
		||||
--
 | 
			
		||||
-- Table structure for table DBTableHosts
 | 
			
		||||
--
 | 
			
		||||
 | 
			
		||||
CREATE TABLE IF NOT EXISTS `$Conf{'DBTableHosts'}` (
 | 
			
		||||
  `id` bigint(20) unsigned NOT NULL auto_increment,
 | 
			
		||||
  `month` varchar(7) character set ascii NOT NULL,
 | 
			
		||||
  `host` varchar(100) NOT NULL,
 | 
			
		||||
  `postings` int(11) NOT NULL,
 | 
			
		||||
  `revision` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
 | 
			
		||||
  PRIMARY KEY  (`id`),
 | 
			
		||||
  UNIQUE KEY `month_host` (`month`,`host`),
 | 
			
		||||
  KEY `month` (`month`),
 | 
			
		||||
  KEY `host` (`host`)
 | 
			
		||||
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='Postings per server';
 | 
			
		||||
HOSTS
 | 
			
		||||
 | 
			
		||||
##### --------------------------------------------------------------------------
 | 
			
		||||
##### Installation / upgrade instructions
 | 
			
		||||
| 
						 | 
				
			
			@ -153,8 +169,8 @@ UPGRADE
 | 
			
		|||
if (!$OptUpdate) {
 | 
			
		||||
  print "----------\nStarting database creation.\n";
 | 
			
		||||
  # create database
 | 
			
		||||
  # we can't use InitDB() as that will use a table name of
 | 
			
		||||
  # the table that doesn't exist yet ...
 | 
			
		||||
  # we can't use InitDB() as that will use the database name of
 | 
			
		||||
  # the database that doesn't exist yet ...
 | 
			
		||||
  my $DBHandle = DBI->connect(sprintf('DBI:%s:host=%s',$Conf{'DBDriver'},
 | 
			
		||||
                                      $Conf{'DBHost'}), $Conf{'DBUser'},
 | 
			
		||||
                                      $Conf{'DBPw'}, { PrintError => 0 });
 | 
			
		||||
| 
						 | 
				
			
			@ -162,7 +178,7 @@ if (!$OptUpdate) {
 | 
			
		|||
  $DBQuery->execute() or &Bleat(2, sprintf("Can't create database %s: %s%\n",
 | 
			
		||||
                                           $Conf{'DBDatabase'}, $DBI::errstr));
 | 
			
		||||
 | 
			
		||||
  printf("Database table %s created succesfully.\n",$Conf{'DBDatabase'});
 | 
			
		||||
  printf("Database %s created succesfully.\n",$Conf{'DBDatabase'});
 | 
			
		||||
  $DBHandle->disconnect;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -185,7 +201,7 @@ if (!$OptUpdate) {
 | 
			
		|||
} else {
 | 
			
		||||
  ##### upgrade mode
 | 
			
		||||
  print "----------\nStarting upgrade process.\n";
 | 
			
		||||
  $PackageVersion = '0.03';
 | 
			
		||||
  my $PackageVersion = '0.03';
 | 
			
		||||
  if ($OptUpdate < $PackageVersion) {
 | 
			
		||||
    if ($OptUpdate < 0.02) {
 | 
			
		||||
      # 0.01 -> 0.02
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue