<?php
/*
* Copyright (c) 2005, Bull S.A.. All rights reserved.
* Created by: Sebastien Decugis
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
*/
/*
This file defines the initial database schema
The output is derived from phpMyAdmin output.
*/
/*************************************************************
*************** Initial database schema *********************
*************************************************************/
/* This creates the release 1 of the database.
* On new installation, this is always the version created then
* the updates are called in order up to the latest release.
*/
function initial_db_schema()
{
$queries = array();
$queries[]="CREATE TABLE `opts_domains` ("
." `dom_id` int(11) NOT NULL auto_increment,"
." `dom_name` varchar(30) NOT NULL default '',"
." `dom_comment` tinytext,"
." PRIMARY KEY (`dom_id`),"
." UNIQUE KEY `dom_name` (`dom_name`)"
.")";
$queries[]="CREATE TABLE `opts_routines` ("
." `rou_id` int(11) NOT NULL auto_increment,"
." `rou_name` varchar(50) NOT NULL default '',"
." `rou_comment` tinytext,"
." PRIMARY KEY (`rou_id`),"
." UNIQUE KEY `rou_name` (`rou_name`)"
.")";
$queries[]="CREATE TABLE `opts_assoc_dom_rou` ("
." `assoc_dom` int(11) NOT NULL default '0',"
." `assoc_rou` int(11) NOT NULL default '0',"
." PRIMARY KEY (`assoc_dom`,`assoc_rou`)"
.")";
$queries[]="CREATE TABLE `opts_assertions` ("
." `assert_id` int(11) NOT NULL auto_increment,"
." `assert_routine` int(11) NOT NULL default '0',"
." `assert_text` text,"
." PRIMARY KEY (`assert_id`)"
.")";
$queries[]="CREATE TABLE `opts_versions` ("
." `ver_id` int(11) NOT NULL auto_increment,"
." `ver_name` varchar(50) NOT NULL default '',"
." `ver_comment` tinytext,"
." `ver_module` varchar(50) NOT NULL default 'opts',"
." PRIMARY KEY (`ver_id`),"
." UNIQUE KEY `ver_name` (`ver_name`),"
." KEY `ver_name_2` (`ver_name`)"
.")";
$queries[]="CREATE TABLE `opts_version_descriptions` ("
." `descr_id` int(11) NOT NULL auto_increment,"
." `descr_version` int(11) NOT NULL default '0',"
." `descr_assert` int(11) NOT NULL default '0',"
." `descr_num_assert` int(11) NOT NULL default '0',"
." `descr_num_test` int(11) NOT NULL default '0',"
." `descr_info` varchar(30) default NULL,"
." PRIMARY KEY (`descr_id`)"
.")";
$queries[]="CREATE TABLE `opts_run` ("
." `run_id` int(11) NOT NULL auto_increment,"
." `run_name` varchar(50) NOT NULL default '',"
." `run_comments` tinytext,"
." PRIMARY KEY (`run_id`),"
." UNIQUE KEY `run_name` (`run_name`)"
.")";
$queries[]="CREATE TABLE `opts_run_results` ("
." `res_run` int(11) NOT NULL default '0',"
." `res_testcase` int(11) NOT NULL default '0',"
." `res_status` varchar(30) NOT NULL default '',"
." `res_log` text,"
." PRIMARY KEY (`res_run`,`res_testcase`)"
.")";
$queries[]="CREATE TABLE `opts_config` ("
."`cfg_key` VARCHAR( 30 ) NOT NULL ,"
."`cfg_val` VARCHAR( 30 ) NOT NULL ,"
."PRIMARY KEY ( `cfg_key` )"
.")";
$queries[]="INSERT INTO `opts_config` ( `cfg_key` , `cfg_val` )"
."VALUES ("
."'version', '1'"
.")";
/* Create the tables */
foreach ($queries as $sql)
{
mysql_query($sql) or die("Unexpected error: ".mysql_error());
}
return "<b>".count($queries)."</b> queries executed.";
}
?>