<?php
require_once(dirname(__FILE__).'/../../upgrade.php');
class create_searchhistory_table extends UPGRADE
{
	/**
	* IsAlreadyUpgraded
	* Do we need to run this classes upgrade script or not ?
	*
	* @return bool true if the upgrade has already run, otherwise false
	*/
	function IsAlreadyUpgraded()
	{
		return $this->TableExists($GLOBALS['tablePrefix'].'searchhistory');
	}

	/**
	* Upgrade
	* Do the actual upgrade of this component. If this is successful all
	* subsequent calls to IsAlreadyUpgraded should return true
	*
	* @return void
	*/
	function Upgrade()
	{
		$query = '
			CREATE TABLE `'.$GLOBALS['tablePrefix']."searchhistory` (
			  `searchstring` varchar(255) NOT NULL default '',
			  `amount` int(10) unsigned NOT NULL default '1',
			  `numresults` int(11) NOT NULL default '0',
			  PRIMARY KEY  (`searchstring`),
			  KEY `ActiveKB_searchhistory_numresults` (`numresults`),
			  FULLTEXT KEY `searchstring` (`searchstring`)
			) ENGINE=MyISAM
		";
		$result = $GLOBALS['AKB_DB']->Query($query);
	}

}
?>
