* Merged the Build and Job tables.
This commit is contained in:
125
src/hydra.sql
125
src/hydra.sql
@ -1,6 +1,15 @@
|
||||
create table builds (
|
||||
-- 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, BuildLogs and
|
||||
-- BuildProducts.
|
||||
create table Builds (
|
||||
id integer primary key autoincrement not null,
|
||||
timestamp integer not null, -- time this build was added to the db (in Unix time)
|
||||
|
||||
finished integer not null, -- 0 = scheduled, 1 = finished
|
||||
|
||||
timestamp integer not null, -- time this build was scheduled / finished building
|
||||
|
||||
-- Info about the inputs.
|
||||
project text not null, -- !!! foreign key
|
||||
@ -11,25 +20,51 @@ create table builds (
|
||||
description text,
|
||||
drvPath text not null,
|
||||
outPath text not null,
|
||||
isCachedBuild integer not null, -- boolean
|
||||
buildStatus integer, -- 0 = succeeded, 1 = Nix build failure, 2 = positive build failure
|
||||
errorMsg text, -- error message in case of a Nix failure
|
||||
startTime integer, -- in Unix time, 0 = used cached build result
|
||||
stopTime integer,
|
||||
system text not null,
|
||||
|
||||
foreign key (project) references projects(name), -- ignored by sqlite
|
||||
foreign key (project, jobset) references jobsets(project, name) -- ignored by sqlite
|
||||
|
||||
foreign key (project) references Projects(name), -- ignored by sqlite
|
||||
foreign key (project, jobset) references Jobsets(project, name) -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
-- Inputs of jobs/builds.
|
||||
create table inputs (
|
||||
-- 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
|
||||
|
||||
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
|
||||
|
||||
buildStatus integer, -- 0 = succeeded, 1 = Nix build failure, 2 = positive build failure
|
||||
|
||||
errorMsg text, -- error message in case of a Nix failure
|
||||
|
||||
startTime integer, -- in Unix time, 0 = used cached build result
|
||||
stopTime integer,
|
||||
|
||||
foreign key (id) references Builds(id) on delete cascade -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
-- Inputs of builds.
|
||||
create table BuildInputs (
|
||||
id integer primary key autoincrement not null,
|
||||
|
||||
-- Which job or build this input belongs to. Exactly one must be non-null.
|
||||
-- Which build this input belongs to.
|
||||
build integer,
|
||||
job integer,
|
||||
|
||||
-- Copied from the jobsetinputs from which the build was created.
|
||||
name text not null,
|
||||
@ -42,29 +77,28 @@ create table inputs (
|
||||
|
||||
path text,
|
||||
|
||||
foreign key (build) references builds(id) -- ignored by sqlite
|
||||
foreign key (job) references jobs(id) -- ignored by sqlite
|
||||
foreign key (dependency) references builds(id) -- ignored by sqlite
|
||||
foreign key (build) references Builds(id) on delete cascade, -- ignored by sqlite
|
||||
foreign key (dependency) references Builds(id) -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
create table buildProducts (
|
||||
create table BuildProducts (
|
||||
build integer not null,
|
||||
path text not null,
|
||||
type text not null, -- "nix-build", "file", "doc", "report", ...
|
||||
subtype text not null, -- "source-dist", "rpm", ...
|
||||
primary key (build, path),
|
||||
foreign key (build) references builds(id) on delete cascade -- ignored by sqlite
|
||||
foreign key (build) references Builds(id) on delete cascade -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
create table buildLogs (
|
||||
create table BuildLogs (
|
||||
build integer not null,
|
||||
logPhase text not null,
|
||||
path text not null,
|
||||
type text not null,
|
||||
primary key (build, logPhase),
|
||||
foreign key (build) references builds(id) on delete cascade -- ignored by sqlite
|
||||
foreign key (build) references Builds(id) on delete cascade -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
@ -72,13 +106,15 @@ create table buildLogs (
|
||||
create trigger cascadeBuildDeletion
|
||||
before delete on builds
|
||||
for each row begin
|
||||
--delete from buildInputs where build = old.id;
|
||||
delete from buildLogs where build = old.id;
|
||||
delete from buildProducts where build = old.id;
|
||||
delete from BuildSchedulingInfo where id = old.id;
|
||||
delete from BuildResultInfo where id = old.id;
|
||||
delete from BuildInputs where build = old.id;
|
||||
delete from BuildLogs where build = old.id;
|
||||
delete from BuildProducts where build = old.id;
|
||||
end;
|
||||
|
||||
|
||||
create table projects (
|
||||
create table Projects (
|
||||
name text primary key not null
|
||||
);
|
||||
|
||||
@ -86,29 +122,29 @@ create table projects (
|
||||
-- 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.
|
||||
create table jobsets (
|
||||
create table Jobsets (
|
||||
name text not null,
|
||||
project text not null,
|
||||
description text,
|
||||
nixExprInput text not null, -- name of the jobsetInput containing the Nix expression
|
||||
nixExprPath text not null, -- relative path of the Nix expression
|
||||
primary key (project, name),
|
||||
foreign key (project) references projects(name) on delete cascade, -- ignored by sqlite
|
||||
foreign key (project, name, nixExprInput) references jobsetInputs(project, job, name)
|
||||
foreign key (project) references Projects(name) on delete cascade, -- ignored by sqlite
|
||||
foreign key (project, name, nixExprInput) references JobsetInputs(project, job, name)
|
||||
);
|
||||
|
||||
|
||||
create table jobsetInputs (
|
||||
create table JobsetInputs (
|
||||
project text not null,
|
||||
jobset text not null,
|
||||
name text not null,
|
||||
type text not null, -- "svn", "cvs", "path", "file", "string"
|
||||
primary key (project, jobset, name),
|
||||
foreign key (project, jobset) references jobsets(project, name) on delete cascade -- ignored by sqlite
|
||||
foreign key (project, jobset) references Jobsets(project, name) on delete cascade -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
create table jobsetInputAlts (
|
||||
create table JobsetInputAlts (
|
||||
project text not null,
|
||||
jobset text not null,
|
||||
input text not null,
|
||||
@ -121,30 +157,5 @@ create table jobsetInputAlts (
|
||||
value text, -- for type == 'string'
|
||||
|
||||
primary key (project, jobset, input, altnr),
|
||||
foreign key (project, jobset, input) references jobsetInputs(project, jobset, name) on delete cascade -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
create table jobs (
|
||||
id integer primary key autoincrement not null,
|
||||
timestamp integer not null, -- time this build was added to the db (in Unix time)
|
||||
|
||||
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?
|
||||
|
||||
-- Info about the inputs.
|
||||
project text not null, -- !!! foreign key
|
||||
jobset text not null, -- !!! foreign key
|
||||
attrName text not null,
|
||||
|
||||
-- What this job will build.
|
||||
description text,
|
||||
drvPath text not null,
|
||||
outPath text not null,
|
||||
system text not null,
|
||||
|
||||
foreign key (project) references projects(name), -- ignored by sqlite
|
||||
foreign key (project, jobset) references jobsets(project, name) -- ignored by sqlite
|
||||
foreign key (project, jobset, input) references JobsetInputs(project, jobset, name) on delete cascade -- ignored by sqlite
|
||||
);
|
||||
|
Reference in New Issue
Block a user