--
-- Table structure for table `act_version`
--

DROP TABLE IF EXISTS `act_version`;
CREATE TABLE `act_version` (
  `id` int unsigned NOT NULL auto_increment,
  `arch_id` int unsigned NOT NULL,
  `arch` char(15) default '',
  `os_group_id` int unsigned NOT NULL,
  `pkg_id` int unsigned NOT NULL,
  `repo_id` int default NULL,
  `act_version` char(100) NOT NULL,
  `act_rel` char(100) default NULL,
  `is_sec` int(1) unsigned default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `arch_id` (`arch_id`,`os_group_id`,`pkg_id`),
  KEY `pkg_id` (`pkg_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `arch`
--

DROP TABLE IF EXISTS `arch`;
CREATE TABLE `arch` (
  `id` int unsigned NOT NULL auto_increment,
  `arch` char(15) default NULL,
  PRIMARY KEY  (`id`),
  KEY `arch_index` (`arch`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `cve`
--

DROP TABLE IF EXISTS `cve`;
CREATE TABLE `cve` (
  `cve_name` char(15) default NULL,
  `cves_id` int unsigned NOT NULL,
  UNIQUE KEY `cve_name` (`cve_name`,`cves_id`),
  KEY `cve_name_2` (`cve_name`),
  KEY `cves_id` (`cves_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `cves`
--

DROP TABLE IF EXISTS `cves`;
CREATE TABLE `cves` (
  `id` int unsigned NOT NULL auto_increment,
  `def_id` varchar(255) NOT NULL,
  `cves_os_id` char(10) NOT NULL,
  `arch_id` int unsigned NOT NULL,
  `pkg_id` int unsigned NOT NULL,
  `version` char(100) NOT NULL,
  `rel` char(100) default '',
  `operator` char(2) NOT NULL,
  `severity` char(50) NOT NULL,
  `title` varchar(255) default '',
  `reference` varchar(255) default '',
  `cve_id` int unsigned NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `def_id` (`def_id`,`cves_os_id`,`pkg_id`,`arch_id`),
  KEY `arch_id` (`arch_id`),
  KEY `cve_id` (`cve_id`),
  KEY `i_pkg_id` (`pkg_id`),
  KEY `cves_os_id` (`cves_os_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `cves_os`
--

DROP TABLE IF EXISTS `cves_os`;
CREATE TABLE `cves_os` (
  `id` char(10) NOT NULL,
  `os_id` int unsigned NOT NULL,
  PRIMARY KEY  (`id`,`os_id`),
  KEY `os_id` (`os_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `domain`
--

DROP TABLE IF EXISTS `domain`;
CREATE TABLE `domain` (
  `id` int unsigned NOT NULL auto_increment,
  `domain` varchar(150) NOT NULL,
  `numhosts` int unsigned NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `domain_index` (`domain`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `host`
--

DROP TABLE IF EXISTS `host`;
CREATE TABLE `host` (
  `id` int unsigned NOT NULL auto_increment,
  `time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `host`char(100) NOT NULL,
  `os_id` int unsigned NOT NULL,
  `kernel` char(70) NOT NULL default '',
  `arch_id` int unsigned NOT NULL,
  `admin` varchar(255) default 'nobody',
  `conn` varchar(20) NOT NULL default '',
  `version` char(5) NOT NULL default '',
  `report_host` varchar(255) NOT NULL default '',
  `report_ip` char(45) NOT NULL default '',
  `dmn_id` int unsigned NOT NULL,
  `type` char(5) NOT NULL,
  `report_md5` char(32) NOT NULL,
  `pkgs_change_timestamp` timestamp,
  PRIMARY KEY  (`id`),
  KEY `arch_id` (`arch_id`),
  KEY `os_id` (`os_id`),
  KEY `dmn_id` (`dmn_id`),
  KEY `host` (`host`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `installed_pkgs`
--

DROP TABLE IF EXISTS `installed_pkgs`;
CREATE TABLE `installed_pkgs` (
  `id` bigint unsigned NOT NULL auto_increment,
  `host_id` int unsigned NOT NULL,
  `pkg_id` int unsigned NOT NULL,
  `version` char(100) default '',
  `rel` char(100) default '',
  `arch` char(15) default '',
  `act_version_id` int default NULL,
  PRIMARY KEY  (`id`),
  KEY `pkg_id` (`pkg_id`),
  UNIQUE KEY `uniq_entry` (`host_id`,`pkg_id`,`arch`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `installed_pkgs_cves`
--

DROP TABLE IF EXISTS `installed_pkgs_cves`;
CREATE TABLE `installed_pkgs_cves` (
  `host_id` int unsigned NOT NULL,
  `installed_pkg_id` bigint unsigned NOT NULL,
  `cve_id` int unsigned NOT NULL,
  KEY `host_id` (`host_id`),
  KEY `installed_pkg_id` (`installed_pkg_id`),
  KEY `cve_id` (`cve_id`),
	UNIQUE KEY `unique_entry` (`host_id`, `installed_pkg_id`, `cve_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `os`
--

DROP TABLE IF EXISTS `os`;
CREATE TABLE `os` (
  `id` int unsigned NOT NULL auto_increment,
  `os` varchar(100) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `os` (`os`),
  KEY `os_index` (`os`(50))
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `os_group`
--

DROP TABLE IF EXISTS `os_group`;
CREATE TABLE `os_group` (
  `id` int unsigned NOT NULL auto_increment,
  `name` varchar(128) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `oses_group`
--

DROP TABLE IF EXISTS `oses_group`;
CREATE TABLE `oses_group` (
  `os_group_id` int unsigned NOT NULL,
  `os_id` int unsigned NOT NULL,
  PRIMARY KEY  (`os_group_id`,`os_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `pkgs`
--

DROP TABLE IF EXISTS `pkgs`;
CREATE TABLE `pkgs` (
  `id` int unsigned NOT NULL auto_increment,
  `name` char(150) NOT NULL default '',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `repositories`
--

DROP TABLE IF EXISTS `repositories`;
CREATE TABLE `repositories` (
  `id` int unsigned NOT NULL auto_increment,
  `name` varchar(1024) NOT NULL,
  `url` varchar(1024) NOT NULL,
  `is_sec` int(1) NOT NULL,
  `type` char(5) NOT NULL,
  `enabled` int(1) default NULL,
  `last_access_ok` int(1) default NULL,
  `arch_id` int unsigned default NULL,
  `os_group_id` int unsigned default NULL,
  `file_checksum` char(33) default NULL,
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `settings`
--

DROP TABLE IF EXISTS `settings`;
CREATE TABLE `settings` (
  `id` int unsigned NOT NULL auto_increment,
  `name` varchar(1024) NOT NULL,
  `value` varchar(4096) NOT NULL,
  `value2` varchar(4096) default NULL,
  PRIMARY KEY  (`id`),
  KEY `name` (`name`(1000))
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int unsigned NOT NULL auto_increment,
  `user` char(128) NOT NULL,
  `dn` char(255) default '',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `dn` (`dn`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_domain`
--

CREATE TABLE `user_domain` (
  `user_id` int unsigned NOT NULL,
  `domain_id` int unsigned NOT NULL,
  PRIMARY KEY  (`user_id`, `domain_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

