Store the inputs of each evaluation in the database

Achtung: this requires a schema upgrade via "hydra-init".
This commit is contained in:
Eelco Dolstra
2012-04-15 18:36:36 +00:00
parent 12dd78d889
commit fd50ac1d4e
6 changed files with 276 additions and 4 deletions

View File

@ -443,6 +443,27 @@ create table JobsetEvals (
);
create table JobsetEvalInputs (
eval integer not null references JobsetEvals(id) on delete cascade,
name text not null,
altNr integer not null,
-- 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,
sha256hash text,
primary key (eval, name, altNr),
foreign key (dependency) references Builds(id)
);
create table JobsetEvalMembers (
eval integer not null references JobsetEvals(id) on delete cascade,
build integer not null references Builds(id) on delete cascade,
@ -521,6 +542,7 @@ create index IndexCachedGitInputsOnHash on CachedGitInputs(uri, branch, sha256ha
create index IndexCachedSubversionInputsOnUriRevision on CachedSubversionInputs(uri, revision);
create index IndexCachedBazaarInputsOnUriRevision on CachedBazaarInputs(uri, revision);
create index IndexJobsetEvalMembersOnBuild on JobsetEvalMembers(build);
create index IndexJobsetEvalMembersOnEval on JobsetEvalMembers(eval);
create index IndexJobsetInputAltsOnInput on JobsetInputAlts(project, jobset, input);
create index IndexJobsetInputAltsOnJobset on JobsetInputAlts(project, jobset);
create index IndexProjectsOnEnabled on Projects(enabled);

50
src/sql/upgrade-6.sql Normal file
View File

@ -0,0 +1,50 @@
create index IndexJobsetEvalMembersOnEval on JobsetEvalMembers(eval);
-- Inputs of jobset evals.
create table JobsetEvalInputs (
eval integer not null references JobsetEvals(id) on delete cascade,
name text not null,
altNr integer not null,
-- 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,
sha256hash text,
primary key (eval, name, altNr),
foreign key (dependency) references Builds(id)
);
-- Reconstruct the repository inputs for pre-existing evals. This is
-- tricky (and not entirely possible) because builds are not uniquely
-- part of a single eval, so they may have different inputs.
-- For Subversion or Bazaar inputs, pick the highest revision for each
-- input.
insert into JobsetEvalInputs (eval, name, altNr, type, uri, revision)
select e.id, b.name, 0, max(b.type), max(b.uri), max(b.revision)
from (select id from JobsetEvals where hasNewBuilds = 1) e
join JobsetEvalMembers m on e.id = m.eval
join BuildInputs b on b.build = m.build
where (b.type = 'svn' or b.type = 'svn-checkout' or b.type = 'bzr' or b.type = 'bzr-checkout')
group by e.id, b.name
having count(distinct type) = 1 and count(distinct uri) = 1;
-- For other inputs there is no "best" revision to pick, so only do
-- the conversion if there is only one.
insert into JobsetEvalInputs (eval, name, altNr, type, uri, revision)
select e.id, b.name, 0, max(b.type), max(uri), max(revision)
from (select id from JobsetEvals where hasNewBuilds = 1) e
join JobsetEvalMembers m on e.id = m.eval
join BuildInputs b on b.build = m.build
where (b.type != 'svn' and b.type != 'svn-checkout' and b.type != 'bzr' and b.type != 'bzr-checkout')
and b.uri is not null and b.revision is not null
and not exists(select 1 from JobsetEvalInputs i where e.id = i.eval and b.name = i.name)
group by e.id, b.name
having count(distinct type) = 1 and count(distinct uri) = 1 and count(distinct revision) = 1;