diff --git a/src/lib/Hydra/Schema/Builds.pm b/src/lib/Hydra/Schema/Builds.pm index 013fd09d..53454867 100644 --- a/src/lib/Hydra/Schema/Builds.pm +++ b/src/lib/Hydra/Schema/Builds.pm @@ -64,6 +64,12 @@ __PACKAGE__->table("builds"); is_foreign_key: 1 is_nullable: 0 +=head2 jobset_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + =head2 job data_type: 'text' @@ -215,6 +221,8 @@ __PACKAGE__->add_columns( { 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 => 1 }, "job", { data_type => "text", is_foreign_key => 1, is_nullable => 0 }, "nixname", @@ -457,6 +465,26 @@ Related object: L __PACKAGE__->belongs_to( "jobset", "Hydra::Schema::Jobsets", + { id => "jobset_id" }, + { + is_deferrable => 0, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "NO ACTION", + }, +); + +=head2 jobset_project_jobset + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "jobset_project_jobset", + "Hydra::Schema::Jobsets", { name => "jobset", project => "project" }, { is_deferrable => 0, on_delete => "NO ACTION", on_update => "CASCADE" }, ); @@ -550,8 +578,8 @@ __PACKAGE__->many_to_many( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-06 12:22:36 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:H3hs+zEywsUmwTWKfSE8wQ +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-06 12:32:28 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RvrINOAowDcde8Nd9VD6rQ __PACKAGE__->has_many( "dependents", diff --git a/src/lib/Hydra/Schema/Jobsets.pm b/src/lib/Hydra/Schema/Jobsets.pm index 60efa962..fbbb253c 100644 --- a/src/lib/Hydra/Schema/Jobsets.pm +++ b/src/lib/Hydra/Schema/Jobsets.pm @@ -257,7 +257,7 @@ __PACKAGE__->has_many( undef, ); -=head2 builds +=head2 builds_jobset_ids Type: has_many @@ -266,7 +266,22 @@ Related object: L =cut __PACKAGE__->has_many( - "builds", + "builds_jobset_ids", + "Hydra::Schema::Builds", + { "foreign.jobset_id" => "self.id" }, + undef, +); + +=head2 builds_project_jobsets + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "builds_project_jobsets", "Hydra::Schema::Builds", { "foreign.jobset" => "self.name", @@ -393,8 +408,27 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-09 15:26:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DH1jX0smo2rFvyr4V+qJcw +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-09 15:32:17 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:P8+t7rgpOqkGwRdM2b+3Bw + + +=head2 builds + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "builds", + "Hydra::Schema::Builds", + { + "foreign.jobset" => "self.name", + "foreign.project" => "self.project", + }, + undef, +); =head2 jobs diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 77b5822a..8349e3be 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -170,6 +170,7 @@ create table Builds ( -- Info about the inputs. project text not null, jobset text not null, + jobset_id integer null, job text not null, -- Info about the build result. @@ -236,6 +237,7 @@ create table Builds ( check (finished = 0 or (stoptime is not null and stoptime != 0)), check (finished = 0 or (starttime is not null and starttime != 0)), + foreign key (jobset_id) references Jobsets(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 diff --git a/src/sql/upgrade-61.sql b/src/sql/upgrade-61.sql new file mode 100644 index 00000000..bfa6b8b3 --- /dev/null +++ b/src/sql/upgrade-61.sql @@ -0,0 +1,10 @@ +-- Add the jobset_id columns to the Builds table. This will go +-- quickly, since the field is nullable. Note this is just part one of +-- this migration. Future steps involve a piecemeal backfilling, and +-- then making the column non-null. + +ALTER TABLE Builds + ADD COLUMN jobset_id integer NULL, + ADD FOREIGN KEY (jobset_id) + REFERENCES Jobsets(id) + ON DELETE CASCADE;