'SET foreign_key_checks=0;

--
-- Table: `accepted_reports`
--
CREATE TABLE `accepted_reports` (
  `id` varchar(255) NOT NULL auto_increment,
  `status` varchar(255) NULL,
  INDEX `pk_id` (`id`),
  PRIMARY KEY (`id`)
);

--
-- Table: `distributions`
--
CREATE TABLE `distributions` (
  `id` integer NOT NULL auto_increment,
  `name` varchar(255) NOT NULL,
  `version` varchar(255) NOT NULL,
  INDEX `pk_id` (`id`),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

--
-- Table: `environments`
--
CREATE TABLE `environments` (
  `id` integer NOT NULL auto_increment,
  `user_agent` varchar(255) NULL,
  `language_id` integer NOT NULL,
  `system_id` integer NOT NULL,
  INDEX `pk_id` (`id`),
  INDEX (`language_id`),
  INDEX (`system_id`),
  PRIMARY KEY (`id`),
  CONSTRAINT `environments_fk` FOREIGN KEY (`language_id`) REFERENCES `languages` (`id`),
  CONSTRAINT `environments_fk_1` FOREIGN KEY (`system_id`) REFERENCES `systems` (`id`)
) ENGINE=InnoDB;

--
-- Table: `environment_toolchains`
--
CREATE TABLE `environment_toolchains` (
  `id` integer NOT NULL auto_increment,
  `key` varchar(255) NULL,
  `value` varchar(255) NULL,
  `toolchain_id` integer NOT NULL,
  INDEX `pk_id` (`id`),
  INDEX (`toolchain_id`),
  PRIMARY KEY (`id`),
  CONSTRAINT `environment_toolchains_fk` FOREIGN KEY (`toolchain_id`) REFERENCES `environments` (`id`)
) ENGINE=InnoDB;

--
-- Table: `languages`
--
CREATE TABLE `languages` (
  `archname` varchar(255) NOT NULL,
  `build` varchar(255) NULL,
  `commit_id` varchar(255) NULL,
  `id` integer NOT NULL auto_increment,
  `implementation` varchar(255) NULL,
  `name` enum(\'Perl 5\', \'Perl 6\') NOT NULL,
  `version` varchar(255) NOT NULL,
  `backend_id` integer NULL,
  INDEX `pk_id` (`id`),
  INDEX (`backend_id`),
  PRIMARY KEY (`id`),
  CONSTRAINT `languages_fk` FOREIGN KEY (`backend_id`) REFERENCES `language_backends` (`id`)
) ENGINE=InnoDB;

--
-- Table: `language_backends`
--
CREATE TABLE `language_backends` (
  `engine` varchar(255) NULL,
  `id` integer NOT NULL auto_increment,
  `version` varchar(255) NULL,
  INDEX `pk_id` (`id`),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

--
-- Table: `language_variables`
--
CREATE TABLE `language_variables` (
  `id` integer NOT NULL auto_increment,
  `key` varchar(255) NULL,
  `value` varchar(255) NULL,
  `variable_id` integer NOT NULL,
  INDEX `pk_id` (`id`),
  INDEX (`variable_id`),
  PRIMARY KEY (`id`),
  CONSTRAINT `language_variables_fk` FOREIGN KEY (`variable_id`) REFERENCES `languages` (`id`)
) ENGINE=InnoDB;

--
-- Table: `prerequisites`
--
CREATE TABLE `prerequisites` (
  `have` varchar(255) NULL,
  `id` integer NOT NULL auto_increment,
  `name` varchar(255) NOT NULL,
  `need` varchar(255) NOT NULL,
  `phase` varchar(255) NOT NULL,
  `prerequisite_id` integer NOT NULL,
  INDEX `pk_id` (`id`),
  INDEX (`prerequisite_id`),
  PRIMARY KEY (`id`),
  CONSTRAINT `prerequisites_fk` FOREIGN KEY (`prerequisite_id`) REFERENCES `distributions` (`id`)
) ENGINE=InnoDB;

--
-- Table: `releases`
--
CREATE TABLE `releases` (
  `author` varchar(255) NULL comment \'The CPAN ID of the author who released this version of this distribution\',
  `dist` varchar(255) NULL comment \'The distribution name\',
  `fail` integer NULL comment \'The number of test failures for this release\',
  `id` integer NOT NULL auto_increment,
  `na` integer NULL comment \'The number of NA results for this release, which means the release does not apply to the tester\'\'s machine due to OS, Perl version, or other conditions\',
  `pass` integer NULL comment \'The number of test passes for this release\',
  `unknown` integer NULL comment \'The number of unknown reports for this release\',
  `version` varchar(255) NULL comment \'The distribution release version\',
  INDEX `pk_id` (`id`),
  PRIMARY KEY (`id`)
) comment=\'A summary of test reports for a single CPAN release\';

--
-- Table: `reports`
--
CREATE TABLE `reports` (
  `comments`  NULL,
  `created` varchar(255) NULL,
  `id` varchar(255) NOT NULL auto_increment,
  `distribution_id` integer NOT NULL,
  `environment_id` integer NOT NULL,
  `reporter_id` integer NOT NULL,
  `result_id` integer NOT NULL,
  INDEX `pk_id` (`id`),
  INDEX (`distribution_id`),
  INDEX (`environment_id`),
  INDEX (`reporter_id`),
  INDEX (`result_id`),
  PRIMARY KEY (`id`),
  CONSTRAINT `reports_fk` FOREIGN KEY (`distribution_id`) REFERENCES `distributions` (`id`),
  CONSTRAINT `reports_fk_1` FOREIGN KEY (`environment_id`) REFERENCES `environments` (`id`),
  CONSTRAINT `reports_fk_2` FOREIGN KEY (`reporter_id`) REFERENCES `reporters` (`id`),
  CONSTRAINT `reports_fk_3` FOREIGN KEY (`result_id`) REFERENCES `results` (`id`)
) ENGINE=InnoDB comment=\'CPAN Testers report\';

--
-- Table: `report_summaries`
--
CREATE TABLE `report_summaries` (
  `date` varchar(255) NULL comment \'The date/time of the report in ISO8601 format\',
  `dist` varchar(255) NULL comment \'The name of the distribution tested\',
  `grade` enum(\'pass\', \'fail\', \'na\', \'unknown\') NULL comment \'The report grade. Pass is passing tests. Fail is failing tests. NA is the distribution cannot be used on the system. Unknown is any other problem.\',
  `guid` varchar(255) NULL comment \'The GUID of the full report this data came from\',
  `id` integer NOT NULL auto_increment,
  `osname` varchar(255) NULL comment \'The name of the operating system, like \'\'linux\'\', \'\'MSWin32\'\', \'\'darwin\'\'\',
  `osvers` varchar(255) NULL comment \'The version of the operating system, like \'\'4.8.0-2-amd64\'\'\',
  `perl` varchar(255) NULL comment \'The Perl version that ran the tests, like \'\'5.24.0\'\'\',
  `platform` varchar(255) NULL comment \'The Perl platform that ran the tests, like \'\'x86_64-linux\'\'\',
  `reporter` varchar(255) NULL comment \'The name/email of the reporter who submitted this report\',
  `version` varchar(255) NULL comment \'The version of the distribution tested\',
  INDEX `pk_id` (`id`),
  PRIMARY KEY (`id`)
) comment=\'Flattened summary data from the test report data structure\';

--
-- Table: `reporters`
--
CREATE TABLE `reporters` (
  `email` varchar(255) NOT NULL,
  `id` integer NOT NULL auto_increment,
  `name` varchar(255) NULL,
  INDEX `pk_id` (`id`),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

--
-- Table: `results`
--
CREATE TABLE `results` (
  `duration` integer NULL,
  `failures` integer NULL,
  `grade` enum(\'pass\', \'fail\', \'na\', \'unknown\') NOT NULL comment \'The report grade. Pass is passing tests. Fail is failing tests. NA is the distribution cannot be used on the system. Unknown is any other problem.\',
  `id` integer NOT NULL auto_increment,
  `skipped` integer NULL,
  `tests` integer NULL,
  `warnings` integer NULL,
  `output_id` integer NOT NULL,
  `todo_id` integer NULL,
  INDEX `pk_id` (`id`),
  INDEX (`output_id`),
  INDEX (`todo_id`),
  PRIMARY KEY (`id`),
  CONSTRAINT `results_fk` FOREIGN KEY (`output_id`) REFERENCES `test_outputs` (`id`),
  CONSTRAINT `results_fk_1` FOREIGN KEY (`todo_id`) REFERENCES `result_todoes` (`id`)
) ENGINE=InnoDB;

--
-- Table: `result_todoes`
--
CREATE TABLE `result_todoes` (
  `fail` integer NOT NULL,
  `id` integer NOT NULL auto_increment,
  `pass` integer NOT NULL,
  INDEX `pk_id` (`id`),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

--
-- Table: `systems`
--
CREATE TABLE `systems` (
  `cpu_count` varchar(255) NULL,
  `cpu_description` varchar(255) NULL,
  `cpu_type` varchar(255) NULL,
  `filesystem` varchar(255) NULL,
  `hostname` varchar(255) NULL,
  `id` integer NOT NULL auto_increment,
  `osname` varchar(255) NOT NULL,
  `osversion` varchar(255) NULL,
  INDEX `pk_id` (`id`),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

--
-- Table: `system_variables`
--
CREATE TABLE `system_variables` (
  `id` integer NOT NULL auto_increment,
  `key` varchar(255) NULL,
  `value` varchar(255) NULL,
  `variable_id` integer NOT NULL,
  INDEX `pk_id` (`id`),
  INDEX (`variable_id`),
  PRIMARY KEY (`id`),
  CONSTRAINT `system_variables_fk` FOREIGN KEY (`variable_id`) REFERENCES `systems` (`id`)
) ENGINE=InnoDB;

--
-- Table: `test_outputs`
--
CREATE TABLE `test_outputs` (
  `build` varchar(255) NULL,
  `configure` varchar(255) NULL,
  `id` integer NOT NULL auto_increment,
  `install` varchar(255) NULL,
  `test` varchar(255) NULL,
  `uncategorized` varchar(255) NULL,
  INDEX `pk_id` (`id`),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB comment=\'At least one of the properties must be set\';

--
-- Table: `uploads`
--
CREATE TABLE `uploads` (
  `author` varchar(255) NULL comment \'The CPAN ID of the author who released this version of this distribution\',
  `dist` varchar(255) NULL comment \'The distribution name\',
  `filename` varchar(255) NULL comment \'The filename on PAUSE, without the author directory\',
  `id` integer NOT NULL auto_increment,
  `released` datetime NULL comment \'The date/time the file was released to CPAN, in UTC\',
  `version` varchar(255) NULL comment \'The distribution release version\',
  INDEX `pk_id` (`id`),
  PRIMARY KEY (`id`)
) comment=\'A release to CPAN\';

SET foreign_key_checks=1;'
