diff --git a/src/lib/Hydra/Schema/JobsetEvals.pm b/src/lib/Hydra/Schema/JobsetEvals.pm index 3fd5b469..0d4a013f 100644 --- a/src/lib/Hydra/Schema/JobsetEvals.pm +++ b/src/lib/Hydra/Schema/JobsetEvals.pm @@ -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 __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 - -=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", diff --git a/src/lib/Hydra/Schema/Jobsets.pm b/src/lib/Hydra/Schema/Jobsets.pm index 6ca83dbb..b2dc0131 100644 --- a/src/lib/Hydra/Schema/Jobsets.pm +++ b/src/lib/Hydra/Schema/Jobsets.pm @@ -301,10 +301,7 @@ Related object: L __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 diff --git a/src/lib/Hydra/Schema/Projects.pm b/src/lib/Hydra/Schema/Projects.pm index d3bd1911..09f92af3 100644 --- a/src/lib/Hydra/Schema/Projects.pm +++ b/src/lib/Hydra/Schema/Projects.pm @@ -157,21 +157,6 @@ __PACKAGE__->has_many( undef, ); -=head2 jobsetevals - -Type: has_many - -Related object: L - -=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 -> 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 => [ diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index ab2c6159..6e56960f 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -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; diff --git a/src/sql/upgrade-72.sql b/src/sql/upgrade-72.sql new file mode 100644 index 00000000..89eab500 --- /dev/null +++ b/src/sql/upgrade-72.sql @@ -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; \ No newline at end of file