<?php
require_once(dirname(__FILE__).'/../../upgrade.php');
class create_idx_q_sortorder 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()
	{
		$table = $GLOBALS['tablePrefix'].'questions';

		$columns = array(
			'sortorder',
		);

		$unique = false;

		$type = 'BTREE';

		return $this->IndexExists($table, $columns, $unique, $type);
	}

	/**
	* 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 INDEX `idx_q_sortorder`
			ON `'.$GLOBALS['tablePrefix'].'questions`(`sortorder`)
		';
		$result = $GLOBALS['AKB_DB']->Query($query);
	}

}
?>
