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

	/**
	* 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']."pageindex` (
				`pageindexid` int(11) NOT NULL auto_increment,
				`fullurl` VARCHAR( 255 ) NOT NULL ,
				`questionid` INT NOT NULL ,
				`content` LONGTEXT NOT NULL ,
				`plugin` VARCHAR( 255 ) NOT NULL ,
				`filename` VARCHAR( 255 ) NOT NULL ,
				`lastupdated` DATETIME NOT NULL ,
				PRIMARY KEY ( `pageindexid` ),
				UNIQUE KEY `idx_pi_fullurl` (`fullurl`),
				KEY `idx_pi_lastupdated` (`lastupdated`),
				FULLTEXT KEY `idx_pi_ft` (`content`,`filename`)
			) ENGINE=MyISAM
		";			

		$result = $GLOBALS['AKB_DB']->Query($query);
	}

}
?>
