#
# Create MySQL tables for Validation Service
#
# 2007-10-17 Nakamegu
#
# Flags (OLD) >> see ../../README
#  package->obsolute
#    0 : latest package
#    1 : obsolute package
#
#  package->vulnerability
#    0 : unknown or no vul.
#    1 : no vul. by OVAL
#    2 : no vul.?
#    3 : vul.
#    4 : vul.?
#   10 : re check
#   11 : no vul. by Admin
#   12 : no vul.?
#   13 : vul
#   14 : vul?
#

DROP TABLE IF EXISTS distributions;
CREATE TABLE IF NOT EXISTS distributions (
	id int UNSIGNED NOT NULL auto_increment,
	name varchar(45) NOT NULL DEFAULT 'na',
	version varchar(45) NOT NULL DEFAULT 'na',
	arch varchar(45) NOT NULL DEFAULT 'na',
	vendor varchar(45) NOT NULL DEFAULT 'na',
	build BIGINT UNSIGNED NOT NULL DEFAULT 0,
	summary varchar(255) NOT NULL DEFAULT 'na',
	previous_version varchar(45), 
	vulnerability TINYINT(1)  NOT NULL DEFAULT 0,
	PRIMARY KEY (id)
);
	
DROP TABLE IF EXISTS packages;
CREATE TABLE IF NOT EXISTS packages (
	id int UNSIGNED NOT NULL auto_increment,
	name varchar(45) NOT NULL DEFAULT 'na',
	version varchar(45) NOT NULL DEFAULT 'na',
	arch varchar(45) NOT NULL DEFAULT 'na',
	vendor varchar(45) NOT NULL DEFAULT 'na',
	build BIGINT UNSIGNED NOT NULL DEFAULT 0,
	summary varchar(255) NOT NULL DEFAULT 'na',
	vulnerability TINYINT(1)  NOT NULL DEFAULT 0,
	obsolete TINYINT(1) NOT NULL DEFAULT 0,
	behavior_model VARCHAR(255),
	runtime_model VARCHAR(255),
	java_ve_module VARCHAR(255),
	c_ve_module VARCHAR(255),
	oval VARCHAR(255),
	cve VARCHAR(500),
	cvss_min varchar(45) default NULL,
	cvss_max varchar(45) default NULL,
	used_distribution_id VARCHAR(255),
	package_size INT(11) DEFAULT 0, 
	package_dependency_num INT(11) DEFAULT 0,
	package_dependency_name VARCHAR(255),
	rpmreponame VARCHAR(45),
	rpmfilename VARCHAR(255),
	rpmfilepath VARCHAR(255),
	rimmfilename VARCHAR(255),
	rimmfilepath VARCHAR(255),
	PRIMARY KEY (id)
) ENGINE = MYISAM;

DROP TABLE IF EXISTS measurements;
CREATE TABLE IF NOT EXISTS measurements (
	id int UNSIGNED NOT NULL auto_increment,
	digest varchar(40),
	alg varchar(45),
	name varchar(255),
	package_id INT,
	vulnerability TINYINT(1) NOT NULL DEFAULT 0,
	obsolete TINYINT(1) NOT NULL DEFAULT 0,
	PRIMARY KEY (id)
) ENGINE = MYISAM;



