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
|
|
|
|
emailOnError integer not null default 0
|
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,
|
|
|
|
owner text not null,
|
|
|
|
homepage text, -- URL for the project
|
|
|
|
foreign key (owner) references Users(userName) on update cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
-- 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,
|
|
|
|
nixExprInput text not null, -- name of the jobsetInput containing the Nix expression
|
|
|
|
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
|
|
|
|
lastCheckedTime integer, -- last time the scheduler looked at this jobset
|
|
|
|
enabled integer not null default 1,
|
2010-01-06 13:07:59 +00:00
|
|
|
enableEmail integer not null default 1,
|
|
|
|
emailOverride text not null,
|
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
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
create table JobsetInputs (
|
|
|
|
project text not null,
|
|
|
|
jobset text not null,
|
|
|
|
name text not null,
|
|
|
|
type text not null, -- "svn", "cvs", "path", "uri", "string", "boolean"
|
|
|
|
primary key (project, jobset, name),
|
|
|
|
foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef POSTGRESQL
|
|
|
|
alter table Jobsets
|
|
|
|
add foreign key (project, name, nixExprInput)
|
|
|
|
references JobsetInputs(project, jobset, name);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2009-11-17 15:16:41 +00:00
|
|
|
revision text, -- for type == 'svn'
|
2009-10-21 12:25:43 +00:00
|
|
|
tag text, -- for type == 'cvs'
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
|
|
|
active integer not null default 1, -- !!! obsolete, remove
|
|
|
|
|
|
|
|
errorMsg text, -- evalution error for this job
|
|
|
|
|
|
|
|
firstEvalTime integer, -- first time the scheduler saw this job
|
|
|
|
lastEvalTime integer, -- last time the scheduler saw this job
|
|
|
|
|
|
|
|
disabled integer not null default 0, -- !!! not currently used
|
|
|
|
|
|
|
|
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
|
|
|
-- 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
|
2008-11-25 00:38:16 +00:00
|
|
|
-- found in several tables, such as BuildResultInfo and BuildProducts.
|
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
|
|
|
|
|
|
|
|
timestamp integer not null, -- time this build was scheduled / finished building
|
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,
|
|
|
|
outPath text not null,
|
2008-11-11 12:54:37 +00:00
|
|
|
system text not null,
|
2008-12-16 15:09:39 +00:00
|
|
|
|
|
|
|
longDescription text, -- meta.longDescription
|
|
|
|
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)
|
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
|
|
|
|
-- instantiated this build. Needed if we want to clone this
|
|
|
|
-- build.
|
|
|
|
nixExprInput text,
|
|
|
|
nixExprPath text,
|
2008-11-11 12:54:37 +00:00
|
|
|
|
2009-10-21 12:25:43 +00: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-11-11 12:54:37 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
-- 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
|
|
|
|
2009-03-14 22:34:22 +00:00
|
|
|
disabled integer not null default 0,
|
2008-11-11 12:54:37 +00:00
|
|
|
|
2008-11-27 02:29:46 +00:00
|
|
|
startTime integer, -- if busy, time we started
|
|
|
|
|
2009-10-21 12:25:43 +00:00
|
|
|
foreign key (id) references Builds(id) on delete cascade
|
2008-11-11 12:54:37 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
-- Info for a finished build.
|
|
|
|
create table BuildResultInfo (
|
|
|
|
id integer primary key not null,
|
|
|
|
|
2008-10-28 17:08:29 +00:00
|
|
|
isCachedBuild integer not null, -- boolean
|
2008-11-25 00:38:16 +00:00
|
|
|
|
|
|
|
-- Status codes:
|
|
|
|
-- 0 = succeeded
|
|
|
|
-- 1 = build of this derivation failed
|
|
|
|
-- 2 = build of some dependency failed
|
|
|
|
-- 3 = other failure (see errorMsg)
|
2009-03-06 12:49:01 +00:00
|
|
|
-- 4 = build cancelled (removed from queue; never built)
|
2009-03-26 15:32:19 +00:00
|
|
|
-- 5 = build not done because a dependency failed previously (obsolete)
|
2008-11-25 00:38:16 +00:00
|
|
|
buildStatus integer,
|
2008-11-11 12:54:37 +00:00
|
|
|
|
2008-10-28 17:08:29 +00:00
|
|
|
errorMsg text, -- error message in case of a Nix failure
|
2008-11-11 12:54:37 +00:00
|
|
|
|
2008-10-28 17:08:29 +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
|
|
|
|
2008-11-25 00:38:16 +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
|
2009-03-09 17:21:10 +00:00
|
|
|
|
2009-03-26 15:32:19 +00:00
|
|
|
failedDepBuild integer, -- obsolete
|
|
|
|
failedDepStepNr integer, -- obsolete
|
2008-11-25 00:38:16 +00:00
|
|
|
|
2009-10-21 12:25:43 +00:00
|
|
|
foreign key (id) references Builds(id) on delete cascade
|
2008-10-10 16:05:05 +00:00
|
|
|
);
|
2008-10-28 10:18:03 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
outPath text,
|
|
|
|
|
|
|
|
logfile text,
|
|
|
|
|
|
|
|
busy integer not null,
|
|
|
|
|
2008-11-26 13:39:15 +00:00
|
|
|
status integer, -- 0 = success, 1 = failed
|
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,
|
|
|
|
|
2009-03-12 14:18:30 +00:00
|
|
|
primary key (build, stepnr),
|
2009-10-21 12:25:43 +00:00
|
|
|
foreign key (build) references Builds(id) on delete cascade
|
2008-11-11 17:49:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
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,
|
2008-11-05 23:08:16 +00: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-05 06:23:41 +00:00
|
|
|
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-05 23:08:16 +00:00
|
|
|
|
2008-11-06 18:26:29 +00:00
|
|
|
path text,
|
2008-11-05 23:08:16 +00:00
|
|
|
|
2008-11-12 23:14:57 +00:00
|
|
|
sha256hash text,
|
|
|
|
|
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", ...
|
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
|
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
|
|
|
);
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
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,
|
2009-11-19 08:15:49 +00:00
|
|
|
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
|
|
|
|
|
|
|
create table SystemTypes (
|
|
|
|
system text primary key not null,
|
|
|
|
maxConcurrent integer not null default 2
|
|
|
|
);
|
2008-11-26 19:48:04 +00:00
|
|
|
|
|
|
|
|
2009-10-15 21:35:19 +00:00
|
|
|
-- Views are a mechanism to automatically group related builds
|
|
|
|
-- together. A view definition consists of a build of some "primary"
|
|
|
|
-- job, plus all builds of the other jobs named in ViewJobs that have
|
|
|
|
-- that build as an input. If there are multiple builds matching a
|
|
|
|
-- ViewJob, then we take the oldest successful build, or the oldest
|
|
|
|
-- unsuccessful build if there is no successful build.
|
|
|
|
create table Views (
|
2008-11-27 15:16:06 +00:00
|
|
|
project text not null,
|
|
|
|
name text not null,
|
|
|
|
|
|
|
|
description text,
|
|
|
|
|
2009-10-15 21:35:19 +00:00
|
|
|
-- If true, don't garbage-collect builds included in this view.
|
2008-11-27 15:16:06 +00:00
|
|
|
keep integer not null default 0,
|
|
|
|
|
|
|
|
primary key (project, name),
|
2009-10-21 12:25:43 +00:00
|
|
|
foreign key (project) references Projects(name) on delete cascade on update cascade
|
2008-11-27 15:16:06 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-10-15 21:35:19 +00:00
|
|
|
create table ViewJobs (
|
2008-11-27 15:16:06 +00:00
|
|
|
project text not null,
|
2009-10-15 21:35:19 +00:00
|
|
|
view_ text not null,
|
2008-11-27 15:16:06 +00:00
|
|
|
|
|
|
|
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,
|
|
|
|
|
2009-10-15 21:35:19 +00:00
|
|
|
-- If set, this is the primary job for the view. There can be
|
|
|
|
-- only one such job per view.
|
2008-11-27 15:16:06 +00:00
|
|
|
isPrimary integer not null default 0,
|
|
|
|
|
|
|
|
description text,
|
|
|
|
|
2009-03-12 14:18:30 +00:00
|
|
|
jobset text not null,
|
2009-10-15 21:35:19 +00:00
|
|
|
|
|
|
|
-- If set, once there is a successful build for every job
|
|
|
|
-- associated with a build of the view's primary job, that set of
|
|
|
|
-- builds is automatically added as a release to the Releases
|
|
|
|
-- table.
|
|
|
|
autoRelease integer not null default 0,
|
2009-03-12 14:18:30 +00:00
|
|
|
|
2009-10-15 21:35:19 +00:00
|
|
|
primary key (project, view_, job, attrs),
|
2009-10-21 12:25:43 +00:00
|
|
|
foreign key (project) references Projects(name) on delete cascade on update cascade,
|
|
|
|
foreign key (project, view_) references Views(project, name) on delete cascade on update cascade
|
2008-11-27 15:16:06 +00:00
|
|
|
);
|
2009-03-23 13:52:24 +00:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-11-17 13:55:22 +00:00
|
|
|
-- This table is used to prevent repeated Nix expression evaluation
|
|
|
|
-- for the same set of inputs for a jobset. In the scheduler, after
|
|
|
|
-- obtaining 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 it's added to the table, and the
|
|
|
|
-- Nix expression for the jobset is evaluated. The hash is computed
|
|
|
|
-- over the command-line arguments to hydra_eval_jobs.
|
|
|
|
create table JobsetInputHashes (
|
|
|
|
project text not null,
|
|
|
|
jobset text not null,
|
|
|
|
hash text not null,
|
|
|
|
timestamp integer not null,
|
|
|
|
primary key (project, jobset, hash),
|
|
|
|
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
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-03-23 13:52:24 +00:00
|
|
|
-- Some indices.
|
2010-02-09 13:47:20 +00:00
|
|
|
create index IndexBuildInputsOnBuild on BuildInputs(build);
|
|
|
|
create index IndexBuildInputsOnDependency on BuildInputs(dependency);
|
|
|
|
create index IndexBuildProducstOnBuildAndType on BuildProducts(build, type);
|
|
|
|
create index IndexBuildProductsOnBuild on BuildProducts(build);
|
2009-07-09 14:48:15 +00:00
|
|
|
create index IndexBuildResultInfo on BuildResultInfo(id); -- primary key index, not created automatically by PostgreSQL
|
2010-02-09 13:47:20 +00:00
|
|
|
create index IndexBuildSchedulingInfoOnBuild on BuildSchedulingInfo(id); -- idem
|
|
|
|
create index IndexBuildStepsOnBuild on BuildSteps(build);
|
|
|
|
create index IndexBuildsOnFinished on Builds(finished);
|
|
|
|
create index IndexBuildsOnIsCurrent on Builds(isCurrent);
|
|
|
|
create index IndexBuildsOnJob on Builds(project, jobset, job);
|
|
|
|
create index IndexBuildsOnJobAndIsCurrent on Builds(project, jobset, job, isCurrent);
|
|
|
|
create index IndexBuildsOnJobAndSystem on Builds(project, jobset, job, system);
|
|
|
|
create index IndexBuildsOnJobset on Builds(project, jobset);
|
|
|
|
create index IndexBuildsOnProject on Builds(project);
|
|
|
|
create index IndexBuildsOnTimestamp on Builds(timestamp);
|
|
|
|
create index IndexJobsetAltsOnJobset on JobsetInputAlts(project, jobset);
|
2009-10-21 12:25:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef SQLITE
|
|
|
|
|
|
|
|
-- Emulate some "on delete/update cascade" foreign key constraints,
|
|
|
|
-- which SQLite doesn't support yet.
|
|
|
|
|
|
|
|
|
|
|
|
create trigger cascadeBuildDeletion
|
|
|
|
before delete on Builds
|
|
|
|
for each row begin
|
|
|
|
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;
|
|
|
|
delete from BuildSteps where build = old.id;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
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 Views set project = new.name where project = old.name;
|
|
|
|
update ViewJobs set project = new.name where project = old.name;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
create trigger cascadeJobsetUpdate
|
|
|
|
update of name on Jobsets
|
|
|
|
for each row begin
|
|
|
|
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;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
create trigger cascadeUserDelete
|
|
|
|
before delete on Users
|
|
|
|
for each row begin
|
|
|
|
delete from UserRoles where userName = old.userName;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
create trigger cascadeViewDelete
|
|
|
|
before delete on Views
|
|
|
|
for each row begin
|
|
|
|
delete from ViewJobs where project = old.project and view_ = old.name;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
create trigger cascadeViewUpdate
|
|
|
|
update of name on Views
|
|
|
|
for each row begin
|
|
|
|
update ViewJobs set view_ = new.name where project = old.project and view_ = old.name;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|