2011-12-05 14:29:29 +01:00
|
|
|
-- Singleton table to keep track of the schema version.
|
|
|
|
create table SchemaVersion (
|
|
|
|
version integer not null
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-10-21 12:25:43 +00:00
|
|
|
create table Users (
|
|
|
|
userName text primary key not null,
|
|
|
|
fullName text,
|
|
|
|
emailAddress text not null,
|
2009-12-18 12:07:45 +00:00
|
|
|
password text not null, -- sha256 hash
|
2013-11-05 11:46:05 +01:00
|
|
|
emailOnError integer not null default 0,
|
2016-05-27 12:00:20 +02:00
|
|
|
type text not null default 'hydra', -- either "hydra" or "persona"
|
|
|
|
publicDashboard boolean not null default false
|
2009-10-21 12:25:43 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
create table UserRoles (
|
|
|
|
userName text not null,
|
|
|
|
role text not null,
|
|
|
|
primary key (userName, role),
|
|
|
|
foreign key (userName) references Users(userName) on delete cascade on update cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
create table Projects (
|
|
|
|
name text primary key not null, -- project id, lowercase (e.g. "patchelf")
|
|
|
|
displayName text not null, -- display name (e.g. "PatchELF")
|
|
|
|
description text,
|
|
|
|
enabled integer not null default 1,
|
2010-06-04 14:43:28 +00:00
|
|
|
hidden integer not null default 0,
|
2009-10-21 12:25:43 +00:00
|
|
|
owner text not null,
|
|
|
|
homepage text, -- URL for the project
|
Enable declarative projects.
This allows fully declarative project specifications. This is best
illustrated by example:
* I create a new project, setting the declarative spec file to
"spec.json" and the declarative input to a git repo pointing
at git://github.com/shlevy/declarative-hydra-example.git
* hydra creates a special ".jobsets" jobset alongside the project
* Just before evaluating the ".jobsets" jobset, hydra fetches
declarative-hydra-example.git, reads spec.json as a jobset spec,
and updates the jobset's configuration accordingly:
{
"enabled": 1,
"hidden": false,
"description": "Jobsets",
"nixexprinput": "src",
"nixexprpath": "default.nix",
"checkinterval": 300,
"schedulingshares": 100,
"enableemail": false,
"emailoverride": "",
"keepnr": 3,
"inputs": {
"src": { "type": "git", "value": "git://github.com/shlevy/declarative-hydra-example.git", "emailresponsible": false },
"nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs.git release-16.03", "emailresponsible": false }
}
}
* When the "jobsets" job of the ".jobsets" jobset completes, hydra
reads its output as a JSON representation of a dictionary of
jobset specs and creates a jobset named "master" configured
accordingly (In this example, this is the same configuration as
.jobsets itself, except using release.nix instead of default.nix):
{
"enabled": 1,
"hidden": false,
"description": "js",
"nixexprinput": "src",
"nixexprpath": "release.nix",
"checkinterval": 300,
"schedulingshares": 100,
"enableemail": false,
"emailoverride": "",
"keepnr": 3,
"inputs": {
"src": { "type": "git", "value": "git://github.com/shlevy/declarative-hydra-example.git", "emailresponsible": false },
"nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs.git release-16.03", "emailresponsible": false }
}
}
2016-03-11 18:14:58 -05:00
|
|
|
declfile text, -- File containing declarative jobset specification
|
|
|
|
decltype text, -- Type of the input containing declarative jobset specification
|
|
|
|
declvalue text, -- Value of the input containing declarative jobset specification
|
2009-10-21 12:25:43 +00:00
|
|
|
foreign key (owner) references Users(userName) on update cascade
|
|
|
|
);
|
|
|
|
|
2011-11-18 20:35:27 +01:00
|
|
|
|
2010-03-10 10:02:25 +00:00
|
|
|
create table ProjectMembers (
|
|
|
|
project text not null,
|
|
|
|
userName text not null,
|
|
|
|
primary key (project, userName),
|
|
|
|
foreign key (project) references Projects(name) on delete cascade on update cascade,
|
|
|
|
foreign key (userName) references Users(userName) on delete cascade on update cascade
|
|
|
|
);
|
|
|
|
|
2009-10-21 12:25:43 +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.
|
|
|
|
create table Jobsets (
|
|
|
|
name text not null,
|
|
|
|
project text not null,
|
|
|
|
description text,
|
2012-08-16 19:07:04 +02:00
|
|
|
nixExprInput text not null, -- name of the jobsetInput containing the Nix or Guix expression
|
|
|
|
nixExprPath text not null, -- relative path of the Nix or Guix expression
|
2009-10-21 12:25:43 +00:00
|
|
|
errorMsg text, -- used to signal the last evaluation error etc. for this jobset
|
|
|
|
errorTime integer, -- timestamp associated with errorMsg
|
2010-05-11 11:10:03 +00:00
|
|
|
lastCheckedTime integer, -- last time the evaluator looked at this jobset
|
2013-02-25 21:04:10 +01:00
|
|
|
triggerTime integer, -- set if we were triggered by a push event
|
2013-10-11 12:01:52 +02:00
|
|
|
enabled integer not null default 1, -- 0 = disabled, 1 = enabled, 2 = one-shot
|
2010-01-06 13:07:59 +00:00
|
|
|
enableEmail integer not null default 1,
|
2010-06-04 14:43:28 +00:00
|
|
|
hidden integer not null default 0,
|
2010-01-06 13:07:59 +00:00
|
|
|
emailOverride text not null,
|
2010-08-10 06:48:45 +00:00
|
|
|
keepnr integer not null default 3,
|
2013-05-02 17:51:38 +02:00
|
|
|
checkInterval integer not null default 300, -- minimum time in seconds between polls (0 = disable polling)
|
2013-09-21 14:47:52 +00:00
|
|
|
schedulingShares integer not null default 100,
|
2013-09-25 16:21:16 +02:00
|
|
|
fetchErrorMsg text,
|
2015-08-12 14:53:34 +02:00
|
|
|
check (schedulingShares > 0),
|
2009-10-21 12:25:43 +00:00
|
|
|
primary key (project, name),
|
|
|
|
foreign key (project) references Projects(name) on delete cascade on update cascade
|
|
|
|
#ifdef SQLITE
|
|
|
|
,
|
|
|
|
foreign key (project, name, nixExprInput) references JobsetInputs(project, jobset, name)
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
2015-08-12 13:17:56 +02:00
|
|
|
#ifdef POSTGRESQL
|
|
|
|
|
|
|
|
create function notifyJobsetSharesChanged() returns trigger as 'begin notify jobset_shares_changed; return null; end;' language plpgsql;
|
|
|
|
create trigger JobsetSharesChanged after update on Jobsets for each row
|
|
|
|
when (old.schedulingShares != new.schedulingShares) execute procedure notifyJobsetSharesChanged();
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-10-21 12:25:43 +00:00
|
|
|
|
2014-04-23 23:12:00 +02:00
|
|
|
create table JobsetRenames (
|
|
|
|
project text not null,
|
|
|
|
from_ text not null,
|
|
|
|
to_ text not null,
|
|
|
|
primary key (project, from_),
|
|
|
|
foreign key (project) references Projects(name) on delete cascade on update cascade,
|
|
|
|
foreign key (project, to_) references Jobsets(project, name) on delete cascade on update cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-10-21 12:25:43 +00:00
|
|
|
create table JobsetInputs (
|
|
|
|
project text not null,
|
|
|
|
jobset text not null,
|
|
|
|
name text not null,
|
2013-09-30 12:03:25 +02:00
|
|
|
type text not null, -- "svn", "path", "uri", "string", "boolean", "nix"
|
2013-10-08 14:47:24 -04:00
|
|
|
emailResponsible integer not null default 0, -- whether to email committers to this input who change a build
|
2009-10-21 12:25:43 +00:00
|
|
|
primary key (project, jobset, name),
|
|
|
|
foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
create table JobsetInputAlts (
|
|
|
|
project text not null,
|
|
|
|
jobset text not null,
|
|
|
|
input text not null,
|
|
|
|
altnr integer not null,
|
|
|
|
|
|
|
|
-- urgh
|
|
|
|
value text, -- for most types, a URI; for 'path', an absolute path; for 'string', an arbitrary value
|
2012-04-15 12:42:46 +00:00
|
|
|
revision text, -- for repositories
|
2013-01-22 14:41:02 +01:00
|
|
|
|
2009-10-21 12:25:43 +00:00
|
|
|
primary key (project, jobset, input, altnr),
|
|
|
|
foreign key (project, jobset, input) references JobsetInputs(project, jobset, name) on delete cascade on update cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
create table Jobs (
|
|
|
|
project text not null,
|
|
|
|
jobset text not null,
|
|
|
|
name text not null,
|
|
|
|
|
|
|
|
primary key (project, jobset, name),
|
|
|
|
foreign key (project) references Projects(name) on delete cascade on update cascade,
|
|
|
|
foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2008-11-11 12:54:37 +00:00
|
|
|
create table Builds (
|
2009-10-21 12:25:43 +00:00
|
|
|
#ifdef POSTGRESQL
|
|
|
|
id serial primary key not null,
|
|
|
|
#else
|
2008-10-28 10:18:03 +00:00
|
|
|
id integer primary key autoincrement not null,
|
2009-10-21 12:25:43 +00:00
|
|
|
#endif
|
2008-11-11 12:54:37 +00:00
|
|
|
|
|
|
|
finished integer not null, -- 0 = scheduled, 1 = finished
|
2013-01-22 14:41:02 +01:00
|
|
|
|
2013-05-23 10:45:49 -04:00
|
|
|
timestamp integer not null, -- time this build was added
|
2008-11-04 18:23:28 +00:00
|
|
|
|
|
|
|
-- Info about the inputs.
|
2009-03-12 14:18:30 +00:00
|
|
|
project text not null,
|
|
|
|
jobset text not null,
|
|
|
|
job text not null,
|
2008-11-04 18:23:28 +00:00
|
|
|
|
|
|
|
-- Info about the build result.
|
2008-11-12 16:42:07 +00:00
|
|
|
nixName text, -- name attribute of the derivation
|
2008-12-16 15:09:39 +00:00
|
|
|
description text, -- meta.description
|
2008-10-28 10:18:03 +00:00
|
|
|
drvPath text not null,
|
2008-11-11 12:54:37 +00:00
|
|
|
system text not null,
|
2008-12-16 15:09:39 +00:00
|
|
|
|
|
|
|
license text, -- meta.license
|
2009-03-04 14:49:21 +00:00
|
|
|
homepage text, -- meta.homepage
|
2009-07-07 13:59:59 +00:00
|
|
|
maintainers text, -- meta.maintainers (concatenated, comma-separated)
|
2010-05-26 08:03:59 +00:00
|
|
|
maxsilent integer default 3600, -- meta.maxsilent
|
|
|
|
timeout integer default 36000, -- meta.timeout
|
2009-10-02 16:06:28 +00:00
|
|
|
|
2015-10-14 21:37:30 +02:00
|
|
|
isChannel integer not null default 0, -- meta.isHydraChannel
|
2009-10-02 16:06:28 +00:00
|
|
|
isCurrent integer default 0,
|
2009-10-26 13:33:48 +00:00
|
|
|
|
|
|
|
-- Copy of the nixExprInput/nixExprPath fields of the jobset that
|
2013-10-04 15:43:51 +02:00
|
|
|
-- instantiated this build. Needed if we want to reproduce this
|
2009-10-26 13:33:48 +00:00
|
|
|
-- build.
|
|
|
|
nixExprInput text,
|
|
|
|
nixExprPath text,
|
2008-11-11 12:54:37 +00:00
|
|
|
|
2015-08-10 16:18:06 +02:00
|
|
|
-- Priority within a jobset, set via meta.schedulingPriority.
|
2008-11-11 12:54:37 +00:00
|
|
|
priority integer not null default 0,
|
|
|
|
|
2015-08-10 16:18:06 +02:00
|
|
|
-- Priority among all builds, used by the admin to bump builds to
|
|
|
|
-- the front of the queue via the web interface.
|
|
|
|
globalPriority integer not null default 0,
|
|
|
|
|
2015-05-28 17:39:29 +02:00
|
|
|
-- FIXME: remove startTime?
|
2013-05-23 10:45:49 -04:00
|
|
|
startTime integer, -- if busy/finished, time we started
|
|
|
|
stopTime integer, -- if finished, time we finished
|
2012-02-29 02:22:49 +01:00
|
|
|
|
2012-03-05 21:52:47 +01:00
|
|
|
-- Information about finished builds.
|
|
|
|
isCachedBuild integer, -- boolean
|
2008-11-25 00:38:16 +00:00
|
|
|
|
2016-03-09 15:15:12 +01:00
|
|
|
-- Status codes used for builds and steps:
|
2008-11-25 00:38:16 +00:00
|
|
|
-- 0 = succeeded
|
2016-03-09 15:15:12 +01:00
|
|
|
-- 1 = regular Nix failure (derivation returned non-zero exit code)
|
|
|
|
-- 2 = build of a dependency failed [builds only]
|
|
|
|
-- 3 = build or step aborted due to misc failure
|
|
|
|
-- 4 = build cancelled (removed from queue; never built) [builds only]
|
|
|
|
-- 5 = [obsolete]
|
|
|
|
-- 6 = failure with output (i.e. $out/nix-support/failed exists) [builds only]
|
|
|
|
-- 7 = build timed out
|
|
|
|
-- 8 = cached failure [steps only; builds use isCachedBuild]
|
2015-06-15 15:07:04 +02:00
|
|
|
-- 9 = unsupported system type
|
2015-10-06 17:35:08 +02:00
|
|
|
-- 10 = log limit exceeded
|
2016-03-09 16:59:38 +01:00
|
|
|
-- 11 = NAR size limit exceeded
|
2008-11-25 00:38:16 +00:00
|
|
|
buildStatus integer,
|
2008-11-11 12:54:37 +00:00
|
|
|
|
2012-03-05 21:52:47 +01:00
|
|
|
size bigint,
|
|
|
|
closureSize bigint,
|
2010-11-11 11:03:50 +00:00
|
|
|
|
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
|
2009-03-09 17:21:10 +00:00
|
|
|
|
2013-05-23 12:05:12 -04:00
|
|
|
check (finished = 0 or (stoptime is not null and stoptime != 0)),
|
|
|
|
check (finished = 0 or (starttime is not null and starttime != 0)),
|
|
|
|
|
2012-03-05 21:52:47 +01:00
|
|
|
foreign key (project) references Projects(name) on update cascade,
|
|
|
|
foreign key (project, jobset) references Jobsets(project, name) on update cascade,
|
|
|
|
foreign key (project, jobset, job) references Jobs(project, jobset, name) on update cascade
|
2008-10-10 16:05:05 +00:00
|
|
|
);
|
2008-10-28 10:18:03 +00:00
|
|
|
|
|
|
|
|
2015-07-08 11:43:35 +02:00
|
|
|
#ifdef POSTGRESQL
|
|
|
|
|
2015-07-08 12:05:32 +02:00
|
|
|
create function notifyBuildsAdded() returns trigger as 'begin notify builds_added; return null; end;' language plpgsql;
|
|
|
|
create trigger BuildsAdded after insert on Builds execute procedure notifyBuildsAdded();
|
|
|
|
|
|
|
|
create function notifyBuildsDeleted() returns trigger as 'begin notify builds_deleted; return null; end;' language plpgsql;
|
|
|
|
create trigger BuildsDeleted after delete on Builds execute procedure notifyBuildsDeleted();
|
|
|
|
|
|
|
|
create function notifyBuildRestarted() returns trigger as 'begin notify builds_restarted; return null; end;' language plpgsql;
|
|
|
|
create trigger BuildRestarted after update on Builds for each row
|
|
|
|
when (old.finished = 1 and new.finished = 0) execute procedure notifyBuildRestarted();
|
|
|
|
|
|
|
|
create function notifyBuildCancelled() returns trigger as 'begin notify builds_cancelled; return null; end;' language plpgsql;
|
|
|
|
create trigger BuildCancelled after update on Builds for each row
|
|
|
|
when (old.finished = 0 and new.finished = 1 and new.buildStatus = 4) execute procedure notifyBuildCancelled();
|
2015-07-08 11:43:35 +02:00
|
|
|
|
2015-08-10 16:18:06 +02:00
|
|
|
create function notifyBuildBumped() returns trigger as 'begin notify builds_bumped; return null; end;' language plpgsql;
|
|
|
|
create trigger BuildBumped after update on Builds for each row
|
|
|
|
when (old.globalPriority != new.globalPriority) execute procedure notifyBuildBumped();
|
|
|
|
|
2015-07-08 11:43:35 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-02-13 16:49:28 +00:00
|
|
|
create table BuildOutputs (
|
|
|
|
build integer not null,
|
|
|
|
name text not null,
|
|
|
|
path text not null,
|
|
|
|
primary key (build, name),
|
|
|
|
foreign key (build) references Builds(id) on delete cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2015-05-28 17:39:29 +02:00
|
|
|
-- TODO: normalize this. Currently there can be multiple BuildSteps
|
|
|
|
-- for a single step.
|
2008-11-11 17:49:50 +00:00
|
|
|
create table BuildSteps (
|
2009-03-12 14:18:30 +00:00
|
|
|
build integer not null,
|
2008-11-11 17:49:50 +00:00
|
|
|
stepnr integer not null,
|
|
|
|
|
|
|
|
type integer not null, -- 0 = build, 1 = substitution
|
|
|
|
|
2009-03-09 17:21:10 +00:00
|
|
|
drvPath text,
|
2008-11-11 17:49:50 +00:00
|
|
|
|
|
|
|
busy integer not null,
|
|
|
|
|
2016-03-09 15:15:12 +01:00
|
|
|
status integer, -- see Builds.buildStatus
|
2008-11-11 17:49:50 +00:00
|
|
|
|
|
|
|
errorMsg text,
|
|
|
|
|
2008-11-26 13:39:15 +00:00
|
|
|
startTime integer,
|
2008-11-11 17:49:50 +00:00
|
|
|
stopTime integer,
|
|
|
|
|
2010-08-31 14:08:59 +00:00
|
|
|
machine text not null default '',
|
2010-08-31 15:27:46 +00:00
|
|
|
system text,
|
2010-08-31 14:08:59 +00:00
|
|
|
|
2015-02-25 16:42:32 +01:00
|
|
|
propagatedFrom integer,
|
|
|
|
|
2016-02-17 10:28:42 +01:00
|
|
|
-- Time in milliseconds spend copying stuff from/to build machines.
|
|
|
|
overhead integer,
|
|
|
|
|
2009-03-12 14:18:30 +00:00
|
|
|
primary key (build, stepnr),
|
2015-02-25 16:42:32 +01:00
|
|
|
foreign key (build) references Builds(id) on delete cascade,
|
|
|
|
foreign key (propagatedFrom) references Builds(id) on delete cascade
|
2008-11-11 17:49:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2013-02-13 16:49:28 +00:00
|
|
|
create table BuildStepOutputs (
|
|
|
|
build integer not null,
|
|
|
|
stepnr integer not null,
|
|
|
|
name text not null,
|
|
|
|
path text not null,
|
|
|
|
primary key (build, stepnr, name),
|
|
|
|
foreign key (build) references Builds(id) on delete cascade,
|
|
|
|
foreign key (build, stepnr) references BuildSteps(build, stepnr) on delete cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2008-11-11 12:54:37 +00:00
|
|
|
-- Inputs of builds.
|
2009-10-21 12:25:43 +00:00
|
|
|
create table BuildInputs (
|
|
|
|
#ifdef POSTGRESQL
|
|
|
|
id serial primary key not null,
|
|
|
|
#else
|
2008-11-09 00:48:36 +00:00
|
|
|
id integer primary key autoincrement not null,
|
2009-10-21 12:25:43 +00:00
|
|
|
#endif
|
2008-11-09 00:48:36 +00:00
|
|
|
|
2008-11-11 12:54:37 +00:00
|
|
|
-- Which build this input belongs to.
|
2008-11-09 00:48:36 +00:00
|
|
|
build integer,
|
2013-01-22 14:41:02 +01:00
|
|
|
|
2008-11-10 10:18:50 +00:00
|
|
|
-- Copied from the jobsetinputs from which the build was created.
|
2008-11-05 06:23:41 +00:00
|
|
|
name text not null,
|
|
|
|
type text not null,
|
|
|
|
uri text,
|
2009-11-17 15:16:41 +00:00
|
|
|
revision text,
|
2008-11-06 18:26:29 +00:00
|
|
|
value text,
|
2013-10-08 14:47:24 -04:00
|
|
|
emailResponsible integer not null default 0,
|
2008-11-09 00:48:36 +00:00
|
|
|
dependency integer, -- build ID of the input, for type == 'build'
|
2008-11-05 23:08:16 +00:00
|
|
|
|
2008-11-06 18:26:29 +00:00
|
|
|
path text,
|
2013-01-22 14:41:02 +01:00
|
|
|
|
2008-11-12 23:14:57 +00:00
|
|
|
sha256hash text,
|
2013-01-22 14:41:02 +01:00
|
|
|
|
2009-10-21 12:25:43 +00:00
|
|
|
foreign key (build) references Builds(id) on delete cascade,
|
|
|
|
foreign key (dependency) references Builds(id)
|
2008-11-05 06:23:41 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
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,
|
2008-10-28 10:18:03 +00:00
|
|
|
type text not null, -- "nix-build", "file", "doc", "report", ...
|
2008-11-07 17:10:34 +00:00
|
|
|
subtype text not null, -- "source-dist", "rpm", ...
|
2011-12-10 14:48:33 -05:00
|
|
|
fileSize bigint,
|
2008-11-12 14:29:32 +00:00
|
|
|
sha1hash text,
|
|
|
|
sha256hash text,
|
|
|
|
path text,
|
|
|
|
name text not null, -- generally just the filename part of `path'
|
2009-03-06 13:34:53 +00:00
|
|
|
defaultPath text, -- if `path' is a directory, the default file relative to `path' to be served
|
2008-11-12 14:29:32 +00:00
|
|
|
primary key (build, productnr),
|
2009-10-21 12:25:43 +00:00
|
|
|
foreign key (build) references Builds(id) on delete cascade
|
2009-03-13 14:49:25 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2015-07-31 00:57:30 +02:00
|
|
|
create table BuildMetrics (
|
|
|
|
build integer not null,
|
|
|
|
name text not null,
|
|
|
|
|
|
|
|
unit text,
|
|
|
|
value double precision not null,
|
|
|
|
|
|
|
|
-- Denormalisation for performance: copy some columns from the
|
|
|
|
-- corresponding build.
|
|
|
|
project text not null,
|
|
|
|
jobset text not null,
|
|
|
|
job text not null,
|
|
|
|
timestamp integer not null,
|
|
|
|
|
|
|
|
primary key (build, name),
|
|
|
|
foreign key (build) references Builds(id) on delete cascade,
|
|
|
|
foreign key (project) references Projects(name) on update cascade,
|
|
|
|
foreign key (project, jobset) references Jobsets(project, name) on update cascade,
|
|
|
|
foreign key (project, jobset, job) references Jobs(project, jobset, name) on update cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2008-11-25 14:59:08 +00:00
|
|
|
-- 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)
|
|
|
|
);
|
2008-11-26 17:14:27 +00:00
|
|
|
|
2011-02-08 13:11:08 +00:00
|
|
|
create table CachedBazaarInputs (
|
|
|
|
uri text not null,
|
|
|
|
revision integer not null,
|
|
|
|
sha256hash text not null,
|
|
|
|
storePath text not null,
|
|
|
|
primary key (uri, revision)
|
|
|
|
);
|
|
|
|
|
2009-11-17 15:16:41 +00:00
|
|
|
create table CachedGitInputs (
|
|
|
|
uri text not null,
|
2009-11-19 08:15:49 +00:00
|
|
|
branch text not null,
|
|
|
|
revision text not null,
|
2009-11-17 15:16:41 +00:00
|
|
|
sha256hash text not null,
|
|
|
|
storePath text not null,
|
2009-11-19 08:15:49 +00:00
|
|
|
primary key (uri, branch, revision)
|
2009-11-17 15:16:41 +00:00
|
|
|
);
|
|
|
|
|
2013-02-05 19:50:58 +01:00
|
|
|
create table CachedDarcsInputs (
|
|
|
|
uri text not null,
|
|
|
|
revision text not null,
|
|
|
|
sha256hash text not null,
|
|
|
|
storePath text not null,
|
|
|
|
revCount integer not null,
|
|
|
|
primary key (uri, revision)
|
|
|
|
);
|
|
|
|
|
2010-07-27 11:14:24 +00:00
|
|
|
create table CachedHgInputs (
|
|
|
|
uri text not null,
|
|
|
|
branch text not null,
|
|
|
|
revision text not null,
|
|
|
|
sha256hash text not null,
|
|
|
|
storePath text not null,
|
|
|
|
primary key (uri, branch, revision)
|
|
|
|
);
|
|
|
|
|
2009-11-17 15:16:41 +00:00
|
|
|
create table CachedCVSInputs (
|
|
|
|
uri text not null,
|
|
|
|
module 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 (uri, module, sha256hash)
|
|
|
|
);
|
|
|
|
|
2008-11-26 17:14:27 +00:00
|
|
|
|
2015-06-17 11:45:20 +02:00
|
|
|
-- FIXME: remove
|
2013-03-05 17:42:16 +01:00
|
|
|
create table SystemTypes (
|
|
|
|
system text primary key not null,
|
|
|
|
maxConcurrent integer not null default 2
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-10-21 15:44:17 +00:00
|
|
|
-- A release is a named set of builds. The ReleaseMembers table lists
|
|
|
|
-- the builds that constitute each release.
|
|
|
|
create table Releases (
|
|
|
|
project text not null,
|
|
|
|
name text not null,
|
|
|
|
|
|
|
|
timestamp integer not null,
|
|
|
|
|
|
|
|
description text,
|
|
|
|
|
|
|
|
primary key (project, name),
|
|
|
|
foreign key (project) references Projects(name) on delete cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
create table ReleaseMembers (
|
|
|
|
project text not null,
|
|
|
|
release_ text not null,
|
|
|
|
build integer not null,
|
|
|
|
|
|
|
|
description text,
|
|
|
|
|
|
|
|
primary key (project, release_, build),
|
|
|
|
foreign key (project) references Projects(name) on delete cascade on update cascade,
|
|
|
|
foreign key (project, release_) references Releases(project, name) on delete cascade on update cascade,
|
|
|
|
foreign key (build) references Builds(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2010-03-05 15:41:10 +00:00
|
|
|
create table JobsetEvals (
|
|
|
|
#ifdef POSTGRESQL
|
|
|
|
id serial primary key not null,
|
|
|
|
#else
|
|
|
|
id integer primary key autoincrement not null,
|
|
|
|
#endif
|
|
|
|
|
2009-11-17 13:55:22 +00:00
|
|
|
project text not null,
|
|
|
|
jobset text not null,
|
2013-01-22 14:41:02 +01:00
|
|
|
|
2010-03-05 15:41:10 +00:00
|
|
|
timestamp integer not null, -- when this entry was added
|
|
|
|
checkoutTime integer not null, -- how long obtaining the inputs took (in seconds)
|
|
|
|
evalTime integer not null, -- how long evaluation took (in seconds)
|
|
|
|
|
|
|
|
-- If 0, then the evaluation of this jobset did not cause any new
|
|
|
|
-- builds to be added to the database. Otherwise, *all* the
|
|
|
|
-- builds resulting from the evaluation of the jobset (including
|
|
|
|
-- existing ones) can be found in the JobsetEvalMembers table.
|
|
|
|
hasNewBuilds integer not null,
|
|
|
|
|
|
|
|
-- Used to prevent repeated Nix expression evaluation for the same
|
2010-05-11 11:10:03 +00:00
|
|
|
-- set of inputs for a jobset. In the evaluator, after obtaining
|
2010-03-05 15:41:10 +00:00
|
|
|
-- the current inputs for a jobset, we hash the inputs together,
|
|
|
|
-- and if the resulting hash already appears in this table, we can
|
|
|
|
-- skip the jobset. Otherwise we proceed. The hash is computed
|
2011-11-30 18:13:35 +01:00
|
|
|
-- over the command-line arguments to hydra-eval-jobs.
|
2009-11-17 13:55:22 +00:00
|
|
|
hash text not null,
|
2010-03-05 15:41:10 +00:00
|
|
|
|
2012-04-15 22:57:10 +00:00
|
|
|
-- Cached stats about the builds.
|
|
|
|
nrBuilds integer,
|
|
|
|
nrSucceeded integer, -- set lazily when all builds are finished
|
|
|
|
|
2009-11-17 13:55:22 +00:00
|
|
|
foreign key (project) references Projects(name) on delete cascade on update cascade,
|
|
|
|
foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade
|
|
|
|
);
|
|
|
|
|
2010-03-05 10:33:36 +00:00
|
|
|
|
2012-04-15 18:36:36 +00:00
|
|
|
create table JobsetEvalInputs (
|
|
|
|
eval integer not null references JobsetEvals(id) on delete cascade,
|
|
|
|
name text not null,
|
|
|
|
altNr integer not null,
|
2013-01-22 14:41:02 +01:00
|
|
|
|
2012-04-15 18:36:36 +00:00
|
|
|
-- Copied from the jobsetinputs from which the build was created.
|
|
|
|
type text not null,
|
|
|
|
uri text,
|
|
|
|
revision text,
|
|
|
|
value text,
|
|
|
|
dependency integer, -- build ID of the input, for type == 'build'
|
|
|
|
|
|
|
|
path text,
|
2013-01-22 14:41:02 +01:00
|
|
|
|
2012-04-15 18:36:36 +00:00
|
|
|
sha256hash text,
|
|
|
|
|
|
|
|
primary key (eval, name, altNr),
|
|
|
|
foreign key (dependency) references Builds(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2010-03-05 15:41:10 +00:00
|
|
|
create table JobsetEvalMembers (
|
|
|
|
eval integer not null references JobsetEvals(id) on delete cascade,
|
|
|
|
build integer not null references Builds(id) on delete cascade,
|
|
|
|
isNew integer not null,
|
|
|
|
primary key (eval, build)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2010-02-25 15:32:56 +00:00
|
|
|
create table UriRevMapper (
|
|
|
|
baseuri text not null,
|
|
|
|
uri text not null,
|
|
|
|
primary key (baseuri)
|
|
|
|
);
|
2009-11-17 13:55:22 +00:00
|
|
|
|
2011-11-18 20:35:27 +01:00
|
|
|
|
2010-04-27 13:29:08 +00:00
|
|
|
create table NewsItems (
|
|
|
|
#ifdef POSTGRESQL
|
|
|
|
id serial primary key not null,
|
|
|
|
#else
|
|
|
|
id integer primary key autoincrement not null,
|
|
|
|
#endif
|
|
|
|
contents text not null,
|
|
|
|
createTime integer not null,
|
|
|
|
author text not null,
|
|
|
|
foreign key (author) references Users(userName) on delete cascade on update cascade
|
|
|
|
);
|
|
|
|
|
2011-11-18 20:35:27 +01:00
|
|
|
|
2013-08-15 02:33:10 +02:00
|
|
|
create table AggregateConstituents (
|
2013-08-14 01:59:29 +02:00
|
|
|
aggregate integer not null references Builds(id) on delete cascade,
|
2013-08-15 02:33:10 +02:00
|
|
|
constituent integer not null references Builds(id) on delete cascade,
|
|
|
|
primary key (aggregate, constituent)
|
2013-08-14 01:59:29 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2013-10-14 20:07:26 +02:00
|
|
|
create table StarredJobs (
|
|
|
|
userName text not null,
|
|
|
|
project text not null,
|
|
|
|
jobset text not null,
|
|
|
|
job text not null,
|
|
|
|
primary key (userName, project, jobset, job),
|
|
|
|
foreign key (userName) references Users(userName) on update cascade on delete cascade,
|
|
|
|
foreign key (project) references Projects(name) on update cascade on delete cascade,
|
|
|
|
foreign key (project, jobset) references Jobsets(project, name) on update cascade on delete cascade,
|
|
|
|
foreign key (project, jobset, job) references Jobs(project, jobset, name) on update cascade on delete cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2015-06-10 14:57:16 +02:00
|
|
|
-- The output paths that have permanently failed.
|
|
|
|
create table FailedPaths (
|
|
|
|
path text primary key not null
|
|
|
|
);
|
|
|
|
|
|
|
|
#ifdef POSTGRESQL
|
|
|
|
|
|
|
|
-- Needed because Postgres doesn't have "ignore duplicate" or upsert
|
|
|
|
-- yet.
|
|
|
|
create rule IdempotentInsert as on insert to FailedPaths
|
|
|
|
where exists (select 1 from FailedPaths where path = new.path)
|
|
|
|
do instead nothing;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2015-06-22 14:06:44 +02:00
|
|
|
create table SystemStatus (
|
|
|
|
what text primary key not null,
|
|
|
|
status json not null
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2013-08-12 20:11:34 +02:00
|
|
|
-- Cache of the number of finished builds.
|
|
|
|
create table NrBuilds (
|
|
|
|
what text primary key not null,
|
|
|
|
count integer not null
|
|
|
|
);
|
|
|
|
|
|
|
|
insert into NrBuilds(what, count) values('finished', 0);
|
|
|
|
|
|
|
|
#ifdef POSTGRESQL
|
|
|
|
|
|
|
|
create function modifyNrBuildsFinished() returns trigger as $$
|
|
|
|
begin
|
|
|
|
if ((tg_op = 'INSERT' and new.finished = 1) or
|
|
|
|
(tg_op = 'UPDATE' and old.finished = 0 and new.finished = 1)) then
|
|
|
|
update NrBuilds set count = count + 1 where what = 'finished';
|
|
|
|
elsif ((tg_op = 'DELETE' and old.finished = 1) or
|
|
|
|
(tg_op = 'UPDATE' and old.finished = 1 and new.finished = 0)) then
|
|
|
|
update NrBuilds set count = count - 1 where what = 'finished';
|
|
|
|
end if;
|
|
|
|
return null;
|
|
|
|
end;
|
|
|
|
$$ language plpgsql;
|
|
|
|
|
|
|
|
create trigger NrBuildsFinished after insert or update or delete on Builds
|
|
|
|
for each row
|
|
|
|
execute procedure modifyNrBuildsFinished();
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2009-03-23 13:52:24 +00:00
|
|
|
-- Some indices.
|
2012-03-07 18:48:10 +01:00
|
|
|
|
2010-02-09 13:47:20 +00:00
|
|
|
create index IndexBuildInputsOnBuild on BuildInputs(build);
|
|
|
|
create index IndexBuildInputsOnDependency on BuildInputs(dependency);
|
2015-07-31 00:57:30 +02:00
|
|
|
create index IndexBuildMetricsOnJobTimestamp on BuildMetrics(project, jobset, job, timestamp desc);
|
2010-02-09 13:47:20 +00:00
|
|
|
create index IndexBuildProducstOnBuildAndType on BuildProducts(build, type);
|
|
|
|
create index IndexBuildProductsOnBuild on BuildProducts(build);
|
2014-09-29 23:03:38 +02:00
|
|
|
create index IndexBuildStepsOnBusy on BuildSteps(busy) where busy = 1;
|
|
|
|
create index IndexBuildStepsOnDrvPath on BuildSteps(drvpath);
|
2015-07-08 12:12:44 +02:00
|
|
|
create index IndexBuildStepsOnPropagatedFrom on BuildSteps(propagatedFrom) where propagatedFrom is not null;
|
2015-07-10 15:08:34 +02:00
|
|
|
create index IndexBuildStepsOnStopTime on BuildSteps(stopTime desc) where startTime is not null and stopTime is not null;
|
2013-02-13 16:49:28 +00:00
|
|
|
create index IndexBuildStepOutputsOnPath on BuildStepOutputs(path);
|
2014-09-29 23:03:38 +02:00
|
|
|
create index IndexBuildsOnFinished on Builds(finished) where finished = 0;
|
|
|
|
create index IndexBuildsOnIsCurrent on Builds(isCurrent) where isCurrent = 1;
|
|
|
|
create index IndexBuildsOnJobsetIsCurrent on Builds(project, jobset, isCurrent) where isCurrent = 1;
|
|
|
|
create index IndexBuildsOnJobIsCurrent on Builds(project, jobset, job, isCurrent) where isCurrent = 1;
|
2010-02-09 13:47:20 +00:00
|
|
|
create index IndexBuildsOnJobset on Builds(project, jobset);
|
|
|
|
create index IndexBuildsOnProject on Builds(project);
|
|
|
|
create index IndexBuildsOnTimestamp on Builds(timestamp);
|
2013-08-12 20:16:28 +02:00
|
|
|
create index IndexBuildsOnFinishedStopTime on Builds(finished, stoptime DESC);
|
2016-03-16 17:04:20 +01:00
|
|
|
create index IndexBuildsOnJobFinishedId on builds(project, jobset, job, system, finished, id DESC);
|
2010-11-19 15:49:55 +00:00
|
|
|
create index IndexBuildsOnDrvPath on Builds(drvPath);
|
2010-07-27 11:14:24 +00:00
|
|
|
create index IndexCachedHgInputsOnHash on CachedHgInputs(uri, branch, sha256hash);
|
2010-02-11 10:42:37 +00:00
|
|
|
create index IndexCachedGitInputsOnHash on CachedGitInputs(uri, branch, sha256hash);
|
|
|
|
create index IndexCachedSubversionInputsOnUriRevision on CachedSubversionInputs(uri, revision);
|
2011-02-08 13:11:08 +00:00
|
|
|
create index IndexCachedBazaarInputsOnUriRevision on CachedBazaarInputs(uri, revision);
|
2010-08-05 14:06:02 +00:00
|
|
|
create index IndexJobsetEvalMembersOnBuild on JobsetEvalMembers(build);
|
2012-04-15 18:36:36 +00:00
|
|
|
create index IndexJobsetEvalMembersOnEval on JobsetEvalMembers(eval);
|
2010-02-11 10:42:37 +00:00
|
|
|
create index IndexJobsetInputAltsOnInput on JobsetInputAlts(project, jobset, input);
|
|
|
|
create index IndexJobsetInputAltsOnJobset on JobsetInputAlts(project, jobset);
|
|
|
|
create index IndexProjectsOnEnabled on Projects(enabled);
|
2010-08-05 14:06:02 +00:00
|
|
|
create index IndexReleaseMembersOnBuild on ReleaseMembers(build);
|
2012-03-07 18:48:10 +01:00
|
|
|
|
|
|
|
-- For hydra-update-gc-roots.
|
2014-09-29 23:03:38 +02:00
|
|
|
create index IndexBuildsOnKeep on Builds(keep) where keep = 1;
|
2012-03-07 18:48:10 +01:00
|
|
|
|
|
|
|
-- To get the most recent eval for a jobset.
|
2015-07-10 15:23:20 +02:00
|
|
|
create index IndexJobsetEvalsOnJobsetId on JobsetEvals(project, jobset, id desc) where hasNewBuilds = 1;
|