jobsetevals: refer to jobset by ID

This commit is contained in:
Graham Christensen 2021-01-25 14:51:33 -05:00
parent 99e3c83358
commit ac3e8a4a59
No known key found for this signature in database
GPG key ID: FE918C3A98C1030F
5 changed files with 39 additions and 60 deletions

View file

@ -42,15 +42,9 @@ __PACKAGE__->table("jobsetevals");
is_nullable: 0
sequence: 'jobsetevals_id_seq'
=head2 project
=head2 jobset_id
data_type: 'text'
is_foreign_key: 1
is_nullable: 0
=head2 jobset
data_type: 'text'
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
@ -124,10 +118,8 @@ __PACKAGE__->add_columns(
is_nullable => 0,
sequence => "jobsetevals_id_seq",
},
"project",
{ data_type => "text", is_foreign_key => 1, is_nullable => 0 },
"jobset",
{ data_type => "text", is_foreign_key => 1, is_nullable => 0 },
"jobset_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"errormsg",
{ data_type => "text", is_nullable => 1 },
"errortime",
@ -179,8 +171,8 @@ Related object: L<Hydra::Schema::Jobsets>
__PACKAGE__->belongs_to(
"jobset",
"Hydra::Schema::Jobsets",
{ name => "jobset", project => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
{ id => "jobset_id" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
);
=head2 jobsetevalinputs
@ -213,24 +205,9 @@ __PACKAGE__->has_many(
undef,
);
=head2 project
Type: belongs_to
Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-25 14:43:28
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:VKQNG53wwdbO8p1CTdX+WA
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-25 14:44:07
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OVxeYH+eoZZrAsAJ2/mAAA
__PACKAGE__->has_many(
"buildIds",

View file

@ -301,10 +301,7 @@ Related object: L<Hydra::Schema::JobsetEvals>
__PACKAGE__->has_many(
"jobsetevals",
"Hydra::Schema::JobsetEvals",
{
"foreign.jobset" => "self.name",
"foreign.project" => "self.project",
},
{ "foreign.jobset_id" => "self.id" },
undef,
);
@ -375,8 +372,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-22 07:11:57
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6P1qlC5oVSPRSgRBp6nmrw
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-25 14:38:14
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7XtIqrrGAIvReqly1kapog
=head2 builds

View file

@ -157,21 +157,6 @@ __PACKAGE__->has_many(
undef,
);
=head2 jobsetevals
Type: has_many
Related object: L<Hydra::Schema::JobsetEvals>
=cut
__PACKAGE__->has_many(
"jobsetevals",
"Hydra::Schema::JobsetEvals",
{ "foreign.project" => "self.name" },
undef,
);
=head2 jobsetrenames
Type: has_many
@ -258,8 +243,8 @@ Composing rels: L</projectmembers> -> username
__PACKAGE__->many_to_many("usernames", "projectmembers", "username");
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-22 07:11:57
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Ff5gJejFu+02b0lInobOoQ
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-25 14:38:14
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+4yWd9UjCyxxLZYDrVUAxA
my %hint = (
columns => [

View file

@ -440,9 +440,7 @@ create table SystemTypes (
create table JobsetEvals (
id serial primary key not null,
project text not null,
jobset text not null,
jobset_id integer not null,
errorMsg text, -- error output from the evaluator
errorTime integer, -- timestamp associated with errorMsg
@ -473,8 +471,7 @@ create table JobsetEvals (
nixExprInput text, -- name of the jobsetInput containing the Nix or Guix expression
nixExprPath text, -- relative path of the Nix or Guix expression
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
foreign key (jobset_id) references Jobsets(id) on delete cascade
);
@ -629,7 +626,8 @@ create index IndexBuildOutputsPath on BuildOutputs using hash(path);
create index IndexBuildsOnKeep on Builds(keep) where keep = 1;
-- To get the most recent eval for a jobset.
create index IndexJobsetEvalsOnJobsetId on JobsetEvals(project, jobset, id desc) where hasNewBuilds = 1;
create index IndexJobsetEvalsOnJobsetId on JobsetEvals(jobset_id, id desc) where hasNewBuilds = 1;
create index IndexJobsetIdEvals on JobsetEvals(jobset_id) where hasNewBuilds = 1;
create index IndexBuildsOnNotificationPendingSince on Builds(notificationPendingSince) where notificationPendingSince is not null;

22
src/sql/upgrade-72.sql Normal file
View file

@ -0,0 +1,22 @@
ALTER TABLE JobsetEvals
ADD COLUMN jobset_id integer NULL,
ADD FOREIGN KEY (jobset_id)
REFERENCES Jobsets(id)
ON DELETE CASCADE;
UPDATE JobsetEvals
SET jobset_id = (
SELECT jobsets.id
FROM jobsets
WHERE jobsets.name = JobsetEvals.jobset
AND jobsets.project = JobsetEvals.project
);
ALTER TABLE JobsetEvals
ALTER COLUMN jobset_id SET NOT NULL,
DROP COLUMN jobset,
DROP COLUMN project;
create index IndexJobsetIdEvals on JobsetEvals(jobset_id) where hasNewBuilds = 1;