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:
Graham Christensen
2020-02-05 17:10:50 -05:00
parent e00030563b
commit efa1f1d4fb
4 changed files with 79 additions and 6 deletions

View File

@ -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
View 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;