forked from lix-project/hydra
Jobs: add a nullable jobset_id foreign key to Jobsets.
Also, adds an explicitly named "jobs" accessor to the Jobsets Schema object, which uses the project/jobset name.
This commit is contained in:
parent
e00030563b
commit
efa1f1d4fb
|
@ -47,6 +47,12 @@ __PACKAGE__->table("jobs");
|
|||
is_foreign_key: 1
|
||||
is_nullable: 0
|
||||
|
||||
=head2 jobset_id
|
||||
|
||||
data_type: 'integer'
|
||||
is_foreign_key: 1
|
||||
is_nullable: 1
|
||||
|
||||
=head2 name
|
||||
|
||||
data_type: 'text'
|
||||
|
@ -59,6 +65,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 },
|
||||
"name",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
);
|
||||
|
@ -130,6 +138,26 @@ Related object: L<Hydra::Schema::Jobsets>
|
|||
__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<Hydra::Schema::Jobsets>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
"jobset_project_jobset",
|
||||
"Hydra::Schema::Jobsets",
|
||||
{ name => "jobset", project => "project" },
|
||||
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
|
||||
);
|
||||
|
@ -169,7 +197,7 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-06 12:22:36
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sYa6dZNK+stMAnTH0Tmn8A
|
||||
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-06 12:30:58
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dFusVjxb423gIEoadAw9sw
|
||||
|
||||
1;
|
||||
|
|
|
@ -275,7 +275,7 @@ __PACKAGE__->has_many(
|
|||
undef,
|
||||
);
|
||||
|
||||
=head2 jobs
|
||||
=head2 jobs_jobset_ids
|
||||
|
||||
Type: has_many
|
||||
|
||||
|
@ -284,7 +284,22 @@ Related object: L<Hydra::Schema::Jobs>
|
|||
=cut
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"jobs",
|
||||
"jobs_jobset_ids",
|
||||
"Hydra::Schema::Jobs",
|
||||
{ "foreign.jobset_id" => "self.id" },
|
||||
undef,
|
||||
);
|
||||
|
||||
=head2 jobs_project_jobsets
|
||||
|
||||
Type: has_many
|
||||
|
||||
Related object: L<Hydra::Schema::Jobs>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"jobs_project_jobsets",
|
||||
"Hydra::Schema::Jobs",
|
||||
{
|
||||
"foreign.jobset" => "self.name",
|
||||
|
@ -378,8 +393,26 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-09 15:25:17
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1CMOaLf9fYRdJBlYiivmxA
|
||||
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-09 15:26:15
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DH1jX0smo2rFvyr4V+qJcw
|
||||
|
||||
=head2 jobs
|
||||
|
||||
Type: has_many
|
||||
|
||||
Related object: L<Hydra::Schema::Jobs>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"jobs",
|
||||
"Hydra::Schema::Jobs",
|
||||
{
|
||||
"foreign.jobset" => "self.name",
|
||||
"foreign.project" => "self.project",
|
||||
},
|
||||
undef,
|
||||
);
|
||||
|
||||
__PACKAGE__->add_column(
|
||||
"+id" => { retrieve_on_insert => 1 }
|
||||
|
|
|
@ -146,9 +146,11 @@ create table JobsetInputAlts (
|
|||
create table Jobs (
|
||||
project text not null,
|
||||
jobset text not null,
|
||||
jobset_id integer null,
|
||||
name text not null,
|
||||
|
||||
primary key (project, jobset, name),
|
||||
foreign key (jobset_id) references Jobsets(id) on delete cascade,
|
||||
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
|
||||
);
|
||||
|
|
10
src/sql/upgrade-60.sql
Normal file
10
src/sql/upgrade-60.sql
Normal file
|
@ -0,0 +1,10 @@
|
|||
-- Add the jobset_id columns to the Jobs 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 Jobs
|
||||
ADD COLUMN jobset_id integer NULL,
|
||||
ADD FOREIGN KEY (jobset_id)
|
||||
REFERENCES Jobsets(id)
|
||||
ON DELETE CASCADE;
|
Loading…
Reference in a new issue