/*
 * Create initial portscout SQL tables
 *
 * Copyright (C) 2006-2008, Shaun Amott <shaun@inerd.com>
 * All rights reserved.
 *
 * $Id: mysql_init.sql,v 1.1 2008/01/24 04:10:35 samott Exp $
 */

CREATE TABLE portdata (
	`id` serial UNIQUE,
	`name` text,
	`distname` text,
	`ver` text,
	`newver` text,
	`comment` text,
	`cat` text,
	`dir` text,
	`home` text,
	`distfiles` text,
	`sufx` text,
	`mastersites` text,
	`updated` timestamp DEFAULT CURRENT_TIMESTAMP,
	`checked` timestamp,
	`maintainer` text,
	`status` text,
	`method` integer,
	`newurl` text,
	`ignore` smallint DEFAULT 0,
	`limitver` text,
	`masterport` text,
	`masterport_id` integer DEFAULT 0,
	`skipbeta` smallint DEFAULT 1,
	`limiteven` smallint,
	`limitwhich` smallint,
	`moved` smallint DEFAULT 0,
	`indexsite` text,
	`skipversions` text,
	`pcfg_static` smallint DEFAULT 0,
	`mailed` text DEFAULT '',
	`systemid` integer
);

CREATE TABLE sitedata (
	`id` serial UNIQUE,
	`failures` integer DEFAULT 0,
	`successes` integer DEFAULT 0,
	`liecount` integer DEFAULT 0,
	`robots` integer DEFAULT 1,
	`robots_paths` text DEFAULT '',
	`type` text,
	`host` text,
	`ignore` smallint DEFAULT 0
);

CREATE TABLE moveddata (
	`id` serial UNIQUE,
	`fromport` text,
	`toport` text,
	`date` text,
	`reason` text
);

CREATE TABLE maildata (
	`id` serial UNIQUE,
	`address` text
);

CREATE TABLE systemdata (
	`id` serial UNIQUE,
	`host` text
);

CREATE TABLE allocators (
	`id` serial UNIQUE,
	`seq` integer NOT NULL,
	`systemid` integer REFERENCES systemdata (id),
	`allocator` text
);

CREATE TABLE portscout (
	`dbver` integer
);

INSERT
  INTO portscout (dbver)
VALUES (2008012301);

CREATE
 INDEX portdata_index_name
    ON portdata (name(128));

CREATE
 INDEX portdata_index_maintainer
    ON portdata (maintainer(128));

CREATE
 INDEX portdata_index_masterport_id
    ON portdata (masterport_id);
