<?php
require_once(dirname(__FILE__).'/../../upgrade.php');
class create_questions_history_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'].'questions_history');
	}

	/**
	* 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']."questions_history` (
			  `versionid` int NOT NULL auto_increment,
			  `questionid` int(11) NOT NULL,
			  `title` varchar(200) NOT NULL default '',
			  `answer` text NOT NULL,
			  `lastupdated` datetime NOT NULL default '0000-00-00 00:00:00',
			  `related` varchar(100) NOT NULL default '',
			  `visible` tinyint(1) NOT NULL default '0',
			  `sortorder` int(11) NOT NULL default '0',
			  `userid` int(11) NOT NULL default '0',
			  `views` int(11) NOT NULL default '0',
			  `posvotes` int(11) NOT NULL default '0',
			  `negvotes` int(11) NOT NULL default '0',
			  `score` int(11) NOT NULL default '0',
			  `emailed` int(11) NOT NULL default '0',
			  `detectrelated` tinyint(1) NOT NULL default '0',
			  `metakeywords` varchar(255) NOT NULL,
			  `metadescription` text NOT NULL,
			  PRIMARY KEY  (`versionid`),
			  KEY (`questionid`),
			  KEY (`lastupdated`)
			)
		";
		$result = $GLOBALS['AKB_DB']->Query($query);
	}

}
?>
