<?php
	/**************************************************************************\
	* phpGroupWare - Setup                                                     *
	* http://www.phpgroupware.org                                              *
	* --------------------------------------------                             *
	* This program is free software; you can redistribute it and/or modify it  *
	* under the terms of the GNU General Public License as published by the    *
	* Free Software Foundation; either version 2 of the License, or (at your   *
	* option) any later version.                                               *
	\**************************************************************************/
	/* $Id: tables_update.inc.php,v 1.13.2.1 2002/05/14 21:43:44 ceb Exp $ */

	$test[] = '0.0.1';
	function netsaint_upgrade0_0_1()
	{
		global $setup_info,$phpgw_setup;

		$phpgw_setup->oProc->CreateTable
		(
			'phpgw_ns_host',array
			(
				'fd' => array
				(
					'h_id' => array('type' => 'auto','nullable' => False),
					'h_name' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'h_owner' => array('type' => 'int','precision' => 4,'nullable' => False),
					'h_access' => array('type' => 'varchar','precision' => 7,'nullable' => False),
					'h_cat' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'h_date' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'h_alias' => array('type' => 'varchar','precision' => 225,'nullable' => False),
					'h_address' => array('type' => 'varchar','precision' => 255,'nullable' => False),
					'h_parent' => array('type' => 'varchar','precision' => 255,'nullable' => False),
					'h_check' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'h_max_attempts' => array('type' => 'int','precision' => 2,'nullable' => False),
					'h_not_intval' => array('type' => 'int','precision' => 2,'nullable' => False),
					'h_not_period' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'h_not_recovery' => array('type' => 'char','precision' => 1,'nullable' => False),
					'h_not_down' => array('type' => 'char','precision' => 1,'nullable' => False),
					'h_not_unreach' => array('type' => 'char','precision' => 1,'nullable' => False),
					'h_event_handler' => array('type' => 'varchar','precision' => 25,'nullable' => False)
				),
				'pk' => array('h_id'),
				'fk' => array(),
				'ix' => array(),
				'uc' => array()
			)
		);

		$phpgw_setup->oProc->CreateTable
		(
			'phpgw_ns_hostgroup',array
			(
				'fd' => array
				(
					'hg_id' => array('type' => 'auto','nullable' => False),
					'hg_name' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'hg_owner' => array('type' => 'int','precision' => 4,'nullable' => False),
					'hg_access' => array('type' => 'varchar','precision' => 7,'nullable' => False),
					'hg_cat' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'hg_date' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'hg_alias' => array('type' => 'varchar','precision' => 255,'nullable' => False),
					'hg_contact' => array('type' => 'varchar','precision' => 255,'nullable' => False),
					'hg_hosts' => array('type' => 'text','nullable' => True)
				),
				'pk' => array('hg_id'),
				'fk' => array(),
				'ix' => array(),
				'uc' => array()
			)
		);

		$setup_info['netsaint']['currentver'] = '0.0.1.001';
		return $setup_info['netsaint']['currentver'];
		//return True;

	}

	$test[] = '0.0.1.001';
	function netsaint_upgrade0_0_1_001()
	{
		global $setup_info,$phpgw_setup;

		$phpgw_setup->oProc->query("CREATE UNIQUE INDEX tp_name ON phpgw_ns_tp(tp_name)");
		$phpgw_setup->oProc->query("CREATE UNIQUE INDEX h_name ON phpgw_ns_host(h_name)");
		$phpgw_setup->oProc->query("CREATE UNIQUE INDEX hg_name ON phpgw_ns_hostgroup(hg_name)");

		$setup_info['netsaint']['currentver'] = '0.0.1.002';
		return $setup_info['netsaint']['currentver'];
	}

	$test[] = '0.0.1.002';
	function netsaint_upgrade0_0_1_002()
	{
		global $setup_info,$phpgw_setup;

		$phpgw_setup->oProc->CreateTable
		(
			'phpgw_ns_contact',array
			(
				'fd' => array
				(
					'c_id' => array('type' => 'auto','nullable' => False),
					'c_name' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'c_owner' => array('type' => 'int','precision' => 4,'nullable' => False),
					'c_access' => array('type' => 'varchar','precision' => 7,'nullable' => False),
					'c_cat' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'c_date' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'c_alias' => array('type' => 'varchar','precision' => 255,'nullable' => False),
					'csv_not_period' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'h_not_period' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'not_service_rec' => array('type' => 'char','precision' => 1,'nullable' => False),
					'not_service_crit' => array('type' => 'char','precision' => 1,'nullable' => False),
					'not_service_warn' => array('type' => 'char','precision' => 1,'nullable' => False),
					'not_host_rec' => array('type' => 'char','precision' => 1,'nullable' => False),
					'not_host_down' => array('type' => 'char','precision' => 1,'nullable' => False),
					'not_host_unreach' => array('type' => 'char','precision' => 1,'nullable' => False),
					'service_not_comand' => array('type' => 'varchar','precision' => 255,'nullable' => False),
					'host_not_comand' => array('type' => 'varchar','precision' => 255,'nullable' => False),
					'c_email' => array('type' => 'varchar','precision' => 50,'nullable' => False),
					'c_pager' => array('type' => 'varchar','precision' => 50,'nullable' => False)
				),
				'pk' => array('c_id'),
				'fk' => array(),
				'ix' => array(),
				'uc' => array('c_name')
			)
		);

		$phpgw_setup->oProc->CreateTable
		(
			'phpgw_ns_contactgroup',array
			(
				'fd' => array
				(
					'cg_id' => array('type' => 'auto','nullable' => False),
					'cg_name' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'cg_owner' => array('type' => 'int','precision' => 4,'nullable' => False),
					'cg_access' => array('type' => 'varchar','precision' => 7,'nullable' => False),
					'cg_cat' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'cg_date' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'cg_alias' => array('type' => 'varchar','precision' => 255,'nullable' => False),
					'cg_contacts' => array('type' => 'text','nullable' => False)
				),
				'pk' => array('cg_id'),
				'fk' => array(),
				'ix' => array(),
				'uc' => array('cg_name')
			)
		);

		$setup_info['netsaint']['currentver'] = '0.0.1.003';
		return $setup_info['netsaint']['currentver'];
	}

	$test[] = '0.0.1.003';
	function netsaint_upgrade0_0_1_003()
	{
		global $setup_info,$phpgw_setup;

		$phpgw_setup->oProc->CreateTable
		(
			'phpgw_ns_service',array
			(
				'fd' => array
				(
					's_id' => array('type' => 'auto','nullable' => False),
					's_owner' => array('type' => 'int','precision' => 4,'nullable' => False),
					's_access' => array('type' => 'varchar','precision' => 7,'nullable' => False),
					's_cat' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					's_date' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					's_host' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					's_descr' => array('type' => 'varchar','precision' => 255,'nullable' => False),
					's_vol' => array('type' => 'char','precision' => 1,'nullable' => False),
					's_period' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					's_max' => array('type' => 'int','precision' => 2,'default' => 0,'nullable' => False),
					'c_intval' => array('type' => 'int','precision' => 2,'default' => 0,'nullable' => False),
					'r_intval' => array('type' => 'int','precision' => 2,'default' => 0,'nullable' => False),
					'cg' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'not_intval' => array('type' => 'int','precision' => 2,'default' => 0,'nullable' => False),
					'not_period' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'not_recover' => array('type' => 'char','precision' => 1,'nullable' => False),
					'not_crit' => array('type' => 'char','precision' => 1,'nullable' => False),
					'not_warn' => array('type' => 'char','precision' => 1,'nullable' => False),
					's_event' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					's_comand' => array('type' => 'varchar','precision' => 25,'nullable' => False)
				),
				'pk' => array('s_id'),
				'fk' => array(),
				'ix' => array(),
				'uc' => array()
			)
		);
		$setup_info['netsaint']['currentver'] = '0.0.1.004';
		return $setup_info['netsaint']['currentver'];
	}

	$test[] = '0.0.1.004';
	function netsaint_upgrade0_0_1_004()
	{
		global $setup_info,$phpgw_setup;

		$phpgw_setup->oProc->CreateTable
		(
			'phpgw_ns_comand',array
			(
				'fd' => array
				(
					'co_id' => array('type' => 'auto','nullable' => False),
					'co_cat' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'co_date' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'co_name' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'co_line' => array('type' => 'text'),
					'co_enabled' => array('type' => 'char','precision' => 1,'nullable' => False)
				),
				'pk' => array('co_id'),
				'fk' => array(),
				'ix' => array(),
				'uc' => array('co_name')
			)
		);

		$phpgw_setup->oProc->AlterColumn('phpgw_ns_tp','sun_time',array('type' => 'varchar','precision' => 255,'nullable' => False));
		$phpgw_setup->oProc->AlterColumn('phpgw_ns_tp','mon_time',array('type' => 'varchar','precision' => 255,'nullable' => False));
		$phpgw_setup->oProc->AlterColumn('phpgw_ns_tp','tue_time',array('type' => 'varchar','precision' => 255,'nullable' => False));
		$phpgw_setup->oProc->AlterColumn('phpgw_ns_tp','wed_time',array('type' => 'varchar','precision' => 255,'nullable' => False));
		$phpgw_setup->oProc->AlterColumn('phpgw_ns_tp','thu_time',array('type' => 'varchar','precision' => 255,'nullable' => False));
		$phpgw_setup->oProc->AlterColumn('phpgw_ns_tp','fri_time',array('type' => 'varchar','precision' => 255,'nullable' => False));
		$phpgw_setup->oProc->AlterColumn('phpgw_ns_tp','sat_time',array('type' => 'varchar','precision' => 255,'nullable' => False));

		$setup_info['netsaint']['currentver'] = '0.0.1.005';
		return $setup_info['netsaint']['currentver'];
	}

	$test[] = '0.0.1.005';
	function netsaint_upgrade0_0_1_005()
	{
		global $setup_info,$phpgw_setup;

		$phpgw_setup->oProc->AddColumn('phpgw_ns_comand','co_type',array('type' => 'varchar','precision' => 4,'default' => 'com','nullable' => False));

		$setup_info['netsaint']['currentver'] = '0.0.1.006';
		return $setup_info['netsaint']['currentver'];
	}

	$test[] = '0.0.1.006';
	function netsaint_upgrade0_0_1_006()
	{
		global $setup_info,$phpgw_setup;

		$phpgw_setup->oProc->CreateTable
		(
			'phpgw_ns_time',array
			(
				'fd' => array
				(
					't_id' => array('type' => 'auto','nullable' => False),
					't_value' => array('type' => 'varchar','precision' => 11,'nullable' => False)
				),
				'pk' => array('t_id'),
				'fk' => array(),
				'ix' => array(),
				'uc' => array()
			)
		);

		$setup_info['netsaint']['currentver'] = '0.0.1.007';
		return $setup_info['netsaint']['currentver'];
	}

	$test[] = '0.0.1.007';
	function netsaint_upgrade0_0_1_007()
	{
		global $setup_info,$phpgw_setup;

		$phpgw_setup->oProc->CreateTable
		(
			'phpgw_ns_escalation',array
			(
				'fd' => array
				(
					'e_id' => array('type' => 'auto','nullable' => False),
					'e_owner' => array('type' => 'int','precision' => 4,'nullable' => False),
					'e_access' => array('type' => 'varchar','precision' => 7,'nullable' => False),
					'e_cat' => array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False),
					'e_date' => array('type' => 'int','precision' => 4,'nullable' => False),
					'e_name' => array('type' => 'varchar','precision' => 25,'nullable' => False),
					'e_type' => array('type' => 'varchar','precision' => 4,'nullable' => False),
					'e_descr' => array('type' => 'varchar','precision' => 255,'nullable' => False),
					'e_first' => array('type' => 'int','precision' => 2,'default' => 0,'nullable' => False),
					'e_last' => array('type' => 'int','precision' => 2,'default' => 0,'nullable' => False),
					'e_c_groups' => array('type' => 'varchar','precision' => 255,'nullable' => False)
				),
				'pk' => array('e_id'),
				'fk' => array(),
				'ix' => array(),
				'uc' => array()
			)
		);

		$setup_info['netsaint']['currentver'] = '0.0.1.008';
		return $setup_info['netsaint']['currentver'];
	}

	$test[] = '0.0.1.008';
	function netsaint_upgrade0_0_1_008()
	{
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('netsaint','manual','hook_manual.inc.php')");
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('netsaint','about','hook_about.inc.php')");
		$GLOBALS['setup_info']['netsaint']['currentver'] = '0.0.1.009';
		return $GLOBALS['setup_info']['netsaint']['currentver'];
	}

	$test[] = '0.0.1.009';
	function netsaint_upgrade0_0_1_009()
	{
        $GLOBALS['setup_info']['netsaint']['currentver'] = '0.0.2';
		return $GLOBALS['setup_info']['netsaint']['currentver'];
	}
?>
