hydra/src/Hydra/sql/hydra.sql

366 lines
12 KiB
MySQL
Raw Normal View History

2008-11-11 12:54:37 +00:00
-- This table contains all builds, either scheduled or finished. For
-- scheduled builds, additional info (such as the priority) can be
-- found in the BuildSchedulingInfo table. For finished builds,
-- additional info (such as the logs, build products, etc.) can be
-- found in several tables, such as BuildResultInfo and BuildProducts.
2008-11-11 12:54:37 +00:00
create table Builds (
id integer primary key autoincrement not null,
2008-11-11 12:54:37 +00:00
finished integer not null, -- 0 = scheduled, 1 = finished
timestamp integer not null, -- time this build was scheduled / finished building
2008-11-04 18:23:28 +00:00
-- Info about the inputs.
project text not null, -- !!! foreign key
2008-11-10 10:18:50 +00:00
jobset text not null, -- !!! foreign key
2008-11-04 18:23:28 +00:00
attrName text not null,
-- Info about the build result.
2008-11-12 16:42:07 +00:00
nixName text, -- name attribute of the derivation
description text, -- meta.description
drvPath text not null,
outPath text not null,
2008-11-11 12:54:37 +00:00
system text not null,
longDescription text, -- meta.longDescription
license text, -- meta.license
2008-11-11 12:54:37 +00:00
foreign key (project) references Projects(name), -- ignored by sqlite
foreign key (project, jobset) references Jobsets(project, name) -- ignored by sqlite
);
-- Info for a scheduled build.
create table BuildSchedulingInfo (
id integer primary key not null,
priority integer not null default 0,
busy integer not null default 0, -- true means someone is building this job now
locker text not null default '', -- !!! hostname/pid of the process building this job?
logfile text, -- if busy, the path of the logfile
2008-11-26 13:39:15 +00:00
disabled integer not null default 0, -- true means hold this job until its re-enabled
2008-11-11 12:54:37 +00:00
2008-11-27 02:29:46 +00:00
startTime integer, -- if busy, time we started
2008-11-11 12:54:37 +00:00
foreign key (id) references Builds(id) on delete cascade -- ignored by sqlite
);
-- Info for a finished build.
create table BuildResultInfo (
id integer primary key not null,
isCachedBuild integer not null, -- boolean
-- Status codes:
-- 0 = succeeded
-- 1 = build of this derivation failed
-- 2 = build of some dependency failed
-- 3 = other failure (see errorMsg)
buildStatus integer,
2008-11-11 12:54:37 +00:00
errorMsg text, -- error message in case of a Nix failure
2008-11-11 12:54:37 +00:00
startTime integer, -- in Unix time, 0 = used cached build result
2008-11-06 18:26:29 +00:00
stopTime integer,
2008-11-10 10:18:50 +00:00
logfile text, -- the path of the logfile
2008-11-25 16:13:22 +00:00
releaseName text, -- e.g. "patchelf-0.5pre1234"
2008-11-26 13:39:15 +00:00
keep integer not null default 0, -- true means never garbage-collect the build output
2008-11-11 12:54:37 +00:00
foreign key (id) references Builds(id) on delete cascade -- ignored by sqlite
);
create table BuildSteps (
id integer not null,
stepnr integer not null,
type integer not null, -- 0 = build, 1 = substitution
drvPath text,
outPath text,
logfile text,
busy integer not null,
2008-11-26 13:39:15 +00:00
status integer, -- 0 = success, 1 = failed
errorMsg text,
2008-11-26 13:39:15 +00:00
startTime integer,
stopTime integer,
primary key (id, stepnr),
foreign key (id) references Builds(id) on delete cascade -- ignored by sqlite
);
2008-11-11 12:54:37 +00:00
-- Inputs of builds.
create table BuildInputs (
2008-11-09 00:48:36 +00:00
id integer primary key autoincrement not null,
2008-11-11 12:54:37 +00:00
-- Which build this input belongs to.
2008-11-09 00:48:36 +00:00
build integer,
2008-11-10 10:18:50 +00:00
-- Copied from the jobsetinputs from which the build was created.
name text not null,
type text not null,
uri text,
revision integer,
tag text,
2008-11-06 18:26:29 +00:00
value text,
2008-11-09 00:48:36 +00:00
dependency integer, -- build ID of the input, for type == 'build'
2008-11-06 18:26:29 +00:00
path text,
2008-11-12 23:14:57 +00:00
sha256hash text,
2008-11-11 12:54:37 +00:00
foreign key (build) references Builds(id) on delete cascade, -- ignored by sqlite
foreign key (dependency) references Builds(id) -- ignored by sqlite
);
2008-11-11 12:54:37 +00:00
create table BuildProducts (
2008-11-09 00:48:36 +00:00
build integer not null,
2008-11-12 14:29:32 +00:00
productnr integer not null,
type text not null, -- "nix-build", "file", "doc", "report", ...
subtype text not null, -- "source-dist", "rpm", ...
2008-11-12 14:29:32 +00:00
fileSize integer,
sha1hash text,
sha256hash text,
path text,
name text not null, -- generally just the filename part of `path'
description text, -- optionally, some description of this file/directory
primary key (build, productnr),
2008-11-11 12:54:37 +00:00
foreign key (build) references Builds(id) on delete cascade -- ignored by sqlite
);
-- Emulate "on delete cascade" foreign key constraints.
create trigger cascadeBuildDeletion
2008-11-17 11:44:51 +00:00
before delete on Builds
for each row begin
2008-11-11 12:54:37 +00:00
delete from BuildSchedulingInfo where id = old.id;
delete from BuildResultInfo where id = old.id;
delete from BuildInputs where build = old.id;
delete from BuildProducts where build = old.id;
end;
2008-11-04 18:23:28 +00:00
2008-11-11 12:54:37 +00:00
create table Projects (
2008-11-12 23:45:11 +00:00
name text primary key not null, -- project id, lowercase (e.g. "patchelf")
displayName text not null, -- display name (e.g. "PatchELF")
2008-11-17 23:59:20 +00:00
description text,
enabled integer not null default 1,
owner text not null,
homepage text, -- URL for the project
foreign key (owner) references Users(userName) -- ignored by sqlite
2008-11-04 18:23:28 +00:00
);
2008-11-13 18:16:57 +00:00
create trigger cascadeProjectUpdate
update of name on Projects
for each row begin
update Jobsets set project = new.name where project = old.name;
update JobsetInputs set project = new.name where project = old.name;
update JobsetInputAlts set project = new.name where project = old.name;
update Builds set project = new.name where project = old.name;
update ReleaseSets set project = new.name where project = old.name;
update ReleaseSetJobs set project = new.name where project = old.name;
2008-11-13 18:16:57 +00:00
end;
2008-11-04 18:23:28 +00:00
-- A jobset consists of a set of inputs (e.g. SVN repositories), one
-- of which contains a Nix expression containing an attribute set
-- describing build jobs.
2008-11-11 12:54:37 +00:00
create table Jobsets (
2008-11-04 18:23:28 +00:00
name text not null,
project text not null,
description text,
2008-11-10 10:18:50 +00:00
nixExprInput text not null, -- name of the jobsetInput containing the Nix expression
2008-11-04 18:23:28 +00:00
nixExprPath text not null, -- relative path of the Nix expression
errorMsg text, -- used to signal the last evaluation error etc. for this jobset
errorTime integer, -- timestamp associated with errorMsg
2008-11-26 13:39:15 +00:00
lastCheckedTime integer, -- last time the scheduler looked at this jobset
2008-11-04 18:23:28 +00:00
primary key (project, name),
2008-11-11 12:54:37 +00:00
foreign key (project) references Projects(name) on delete cascade, -- ignored by sqlite
foreign key (project, name, nixExprInput) references JobsetInputs(project, job, name)
2008-11-04 18:23:28 +00:00
);
2008-11-13 18:16:57 +00:00
create trigger cascadeJobsetUpdate
2008-11-17 11:44:51 +00:00
update of name on Jobsets
2008-11-13 18:16:57 +00:00
for each row begin
2008-11-17 11:44:51 +00:00
update JobsetInputs set jobset = new.name where project = old.project and jobset = old.name;
update JobsetInputAlts set jobset = new.name where project = old.project and jobset = old.name;
update Builds set jobset = new.name where project = old.project and jobset = old.name;
2008-11-13 18:16:57 +00:00
end;
2008-11-11 12:54:37 +00:00
create table JobsetInputs (
2008-11-04 18:23:28 +00:00
project text not null,
2008-11-06 18:26:29 +00:00
jobset text not null,
2008-11-04 18:23:28 +00:00
name text not null,
2008-11-25 18:34:24 +00:00
type text not null, -- "svn", "cvs", "path", "uri", "string", "boolean"
2008-11-06 18:26:29 +00:00
primary key (project, jobset, name),
2008-11-11 12:54:37 +00:00
foreign key (project, jobset) references Jobsets(project, name) on delete cascade -- ignored by sqlite
2008-11-06 18:26:29 +00:00
);
2008-11-17 11:44:51 +00:00
create trigger cascadeJobsetInputUpdate
update of name on JobsetInputs
for each row begin
update JobsetInputAlts set input = new.name where project = old.project and jobset = old.jobset and input = old.name;
end;
create trigger cascadeJobsetInputDelete
before delete on JobsetInputs
for each row begin
delete from JobsetInputAlts where project = old.project and jobset = old.jobset and input = old.name;
end;
2008-11-11 12:54:37 +00:00
create table JobsetInputAlts (
2008-11-06 18:26:29 +00:00
project text not null,
jobset text not null,
input text not null,
2008-11-17 11:44:51 +00:00
altnr integer not null,
2008-11-06 18:26:29 +00:00
-- urgh
2008-11-17 11:44:51 +00:00
value text, -- for most types, a URI; for 'path', an absolute path; for 'string', an arbitrary value
2008-11-06 18:26:29 +00:00
revision integer, -- for type == 'svn'
tag text, -- for type == 'cvs'
primary key (project, jobset, input, altnr),
2008-11-11 12:54:37 +00:00
foreign key (project, jobset, input) references JobsetInputs(project, jobset, name) on delete cascade -- ignored by sqlite
);
-- Cache for inputs of type "path" (used for testing Hydra), storing
-- the SHA-256 hash and store path for each source path. Also stores
-- the timestamp when we first saw the path have these contents, which
-- may be used to generate release names.
create table CachedPathInputs (
srcPath text not null,
timestamp integer not null, -- when we first saw this hash
lastSeen integer not null, -- when we last saw this hash
sha256hash text not null,
storePath text not null,
primary key (srcPath, sha256hash)
);
2008-11-25 18:13:55 +00:00
create table CachedSubversionInputs (
uri text not null,
revision integer not null,
sha256hash text not null,
storePath text not null,
primary key (uri, revision)
);
create table SystemTypes (
system text primary key not null,
maxConcurrent integer not null default 2
);
2008-11-26 19:48:04 +00:00
create table Users (
userName text primary key not null,
fullName text,
emailAddress text not null,
password text not null -- sha256 hash
);
create table UserRoles (
userName text not null,
role text not null,
primary key (userName, role),
foreign key (userName) references Users(userName) -- ignored by sqlite
);
create trigger cascadeUserDelete
before delete on Users
for each row begin
delete from UserRoles where userName = old.userName;
end;
-- Release sets are a mechanism to automatically group related builds
-- together. A release set defines what an individual release
-- consists of, namely: a release consists of a build of some
-- "primary" job, plus all builds of the other jobs named in
-- ReleaseSetJobs that have that build as an input. If there are
2008-11-30 00:23:33 +00:00
-- multiple builds matching a ReleaseSetJob, then we take the oldest
-- successful build, or the oldest unsuccessful build if there is no
-- successful build. A release is itself considered successful if all
-- builds (except those for jobs that have mayFail set) are
-- successful.
--
-- Note that individual releases aren't separately stored in the
-- database, so they're really just a dynamic view on the universe of
-- builds, defined by a ReleaseSet.
create table ReleaseSets (
project text not null,
name text not null,
description text,
-- If true, don't garbage-collect builds belonging to the releases
-- defined by this row.
keep integer not null default 0,
primary key (project, name),
foreign key (project) references Projects(name) on delete cascade -- ignored by sqlite
);
create trigger cascadeReleaseSetDelete
before delete on ReleaseSets
for each row begin
2008-11-28 10:23:00 +00:00
delete from ReleaseSetJobs where project = old.project and release = old.name;
end;
2008-11-27 21:08:17 +00:00
create trigger cascadeReleaseSetUpdate
update of name on ReleaseSets
for each row begin
update ReleaseSetJobs set release = new.name where project = old.project and release = old.name;
end;
create table ReleaseSetJobs (
project text not null,
-- !!! urgh: "release" is a reserved keyword in sqlite >= 3.6.8!
release text not null,
job text not null,
-- A constraint on the job consisting of `name=value' pairs,
-- e.g. "system=i686-linux officialRelease=true". Should really
-- be a separate table but I'm lazy.
attrs text not null,
-- If set, this is the primary job for the release. There can be
-- onlyt one such job per release set.
isPrimary integer not null default 0,
mayFail integer not null default 0,
description text,
primary key (project, release, job, attrs),
foreign key (project) references Projects(name) on delete cascade, -- ignored by sqlite
foreign key (project, release) references ReleaseSets(project, name) on delete cascade -- ignored by sqlite
);