Skip to content

Instantly share code, notes, and snippets.

@robsimmons
Last active September 1, 2017 20:10
Show Gist options
  • Save robsimmons/28c9529900442d17eea19489c690f294 to your computer and use it in GitHub Desktop.
Save robsimmons/28c9529900442d17eea19489c690f294 to your computer and use it in GitHub Desktop.
CREATE TABLE `feedback` (
`job` int NOT NULL,
`task` char(20) NOT NULL,
`payload` longtext NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY `job` (`job`, `task`),
CONSTRAINT `feedback_job` FOREIGN KEY (`job`) REFERENCES `job` (`job`) ON DELETE CASCADE
);
CREATE TABLE `job` (
`job` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`submission` INT NOT NULL,
`status` enum('waiting', 'assigned', 'partial', 'done', 'quarantined') NOT NULL DEFAULT 'waiting',
`payload` JSON NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_touched` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`worker` char(13) DEFAULT NULL,
UNIQUE KEY `submission` (`submission`),
KEY `status` (`status`),
CONSTRAINT `job_submission` FOREIGN KEY (`submission`) REFERENCES `submission` (`submission`)
);
CREATE TABLE `result` (
`job` int NOT NULL,
`task` char(20) NOT NULL,
`payload` json NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY `job` (`job`, `task`),
CONSTRAINT `result_job` FOREIGN KEY (`job`) REFERENCES `job` (`job`) ON DELETE CASCADE
);
CREATE TABLE `submission` (
`submission` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`hash` binary(20) NOT NULL,
`branch` char(16) NOT NULL,
`groupname` char(16) NOT NULL,
`type` enum('tests', 'compiler', 'sleep') NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY `hash` (`hash`, `branch`, `groupname`),
KEY `groupname` (`groupname`)
);
CREATE TABLE `worker` (
`worker` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`finished` bool NOT NULL DEFAULT '0',
`status` enum('REQUESTED', 'STARTING', 'IDLE', 'IDLE_TASKED', 'WORKING', 'BORED', 'KILLED', 'KILLED_TASKED', 'LOST', 'LOST_TASKED', 'LOST_TERM') NOT NULL DEFAULT 'REQUESTED',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_touched` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`worker_ping` timestamp DEFAULT NULL,
`spinner_ping` timestamp DEFAULT NULL,
`job` int DEFAULT NULL,
`note` varchar(255) DEFAULT NULL,
UNIQUE KEY `job` (`job`),
CONSTRAINT `worker_job` FOREIGN KEY (`job`) REFERENCES `job` (`job`)
);
CREATE TABLE `worker_counter` (
`type` char(10) NOT NULL PRIMARY KEY,
`next` int NOT NULL
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment