From 6fe57ab5fad9f2728f9d6de6b296fe8187a6bd72 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sun, 9 Feb 2020 15:17:24 -0500 Subject: [PATCH] Copy the flake migration from the flake branch hydra.nixos.org is already running this rev, and it should be safe to apply to everyone else. If we make changes to this migration, we'll need to write another migration anyway. --- src/lib/Hydra/Schema/JobsetEvals.pm | 11 +++++++++-- src/lib/Hydra/Schema/Jobsets.pm | 27 +++++++++++++++++++++------ src/sql/hydra.sql | 13 ++++++++++--- src/sql/upgrade-58.sql | 7 +++++++ 4 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 src/sql/upgrade-58.sql diff --git a/src/lib/Hydra/Schema/JobsetEvals.pm b/src/lib/Hydra/Schema/JobsetEvals.pm index 5558b39a..7e88c25e 100644 --- a/src/lib/Hydra/Schema/JobsetEvals.pm +++ b/src/lib/Hydra/Schema/JobsetEvals.pm @@ -89,6 +89,11 @@ __PACKAGE__->table("jobsetevals"); data_type: 'integer' is_nullable: 1 +=head2 flake + + data_type: 'text' + is_nullable: 1 + =cut __PACKAGE__->add_columns( @@ -117,6 +122,8 @@ __PACKAGE__->add_columns( { data_type => "integer", is_nullable => 1 }, "nrsucceeded", { data_type => "integer", is_nullable => 1 }, + "flake", + { data_type => "text", is_nullable => 1 }, ); =head1 PRIMARY KEY @@ -194,8 +201,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-06 12:22:36 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4ZaT8Z1tmCCt6k4ein0MNg +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-09 15:21:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Ar6GRni8AcAQmuZyg6tFKw __PACKAGE__->has_many( "buildIds", diff --git a/src/lib/Hydra/Schema/Jobsets.pm b/src/lib/Hydra/Schema/Jobsets.pm index a69bd599..9e9d4773 100644 --- a/src/lib/Hydra/Schema/Jobsets.pm +++ b/src/lib/Hydra/Schema/Jobsets.pm @@ -54,12 +54,12 @@ __PACKAGE__->table("jobsets"); =head2 nixexprinput data_type: 'text' - is_nullable: 0 + is_nullable: 1 =head2 nixexprpath data_type: 'text' - is_nullable: 0 + is_nullable: 1 =head2 errormsg @@ -137,6 +137,17 @@ __PACKAGE__->table("jobsets"); data_type: 'integer' is_nullable: 1 +=head2 type + + data_type: 'integer' + default_value: 0 + is_nullable: 0 + +=head2 flake + + data_type: 'text' + is_nullable: 1 + =cut __PACKAGE__->add_columns( @@ -147,9 +158,9 @@ __PACKAGE__->add_columns( "description", { data_type => "text", is_nullable => 1 }, "nixexprinput", - { data_type => "text", is_nullable => 0 }, + { data_type => "text", is_nullable => 1 }, "nixexprpath", - { data_type => "text", is_nullable => 0 }, + { data_type => "text", is_nullable => 1 }, "errormsg", { data_type => "text", is_nullable => 1 }, "errortime", @@ -178,6 +189,10 @@ __PACKAGE__->add_columns( { data_type => "boolean", is_nullable => 1 }, "starttime", { data_type => "integer", is_nullable => 1 }, + "type", + { data_type => "integer", default_value => 0, is_nullable => 0 }, + "flake", + { data_type => "text", is_nullable => 1 }, ); =head1 PRIMARY KEY @@ -335,8 +350,8 @@ __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:fYKx6VRlNG5XiDZ73Qr6Rw +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-09 15:21:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FVP1/AWjdKTlY6djrG592A my %hint = ( columns => [ diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 0c769a7e..33ecab4d 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -54,8 +54,8 @@ create table Jobsets ( name text not null, project text not null, description text, - nixExprInput text not null, -- name of the jobsetInput containing the Nix or Guix expression - nixExprPath text not null, -- relative path of the Nix or Guix expression + nixExprInput text, -- name of the jobsetInput containing the Nix or Guix expression + nixExprPath text, -- relative path of the Nix or Guix expression errorMsg text, -- used to signal the last evaluation error etc. for this jobset errorTime integer, -- timestamp associated with errorMsg lastCheckedTime integer, -- last time the evaluator looked at this jobset @@ -70,7 +70,11 @@ create table Jobsets ( fetchErrorMsg text, forceEval boolean, startTime integer, -- if jobset is currently running + type integer not null default 0, -- 0 == legacy, 1 == flake + flake text, check (schedulingShares > 0), + check ((type = 0) = (nixExprInput is not null and nixExprPath is not null)), + check ((type = 1) = (flake is not null)), primary key (project, name), foreign key (project) references Projects(name) on delete cascade on update cascade #ifdef SQLITE @@ -181,7 +185,8 @@ create table Builds ( -- Copy of the nixExprInput/nixExprPath fields of the jobset that -- instantiated this build. Needed if we want to reproduce this - -- build. + -- build. FIXME: this should be stored in JobsetEvals, storing it + -- here is denormal. nixExprInput text, nixExprPath text, @@ -522,6 +527,8 @@ create table JobsetEvals ( nrBuilds integer, nrSucceeded integer, -- set lazily when all builds are finished + flake text, -- immutable flake reference + 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 ); diff --git a/src/sql/upgrade-58.sql b/src/sql/upgrade-58.sql new file mode 100644 index 00000000..b59ee949 --- /dev/null +++ b/src/sql/upgrade-58.sql @@ -0,0 +1,7 @@ +alter table Jobsets alter column nixExprInput drop not null; +alter table Jobsets alter column nixExprPath drop not null; +alter table Jobsets add column type integer default 0; +alter table Jobsets add column flake text; +alter table Jobsets add check ((type = 0) = (nixExprInput is not null and nixExprPath is not null)); +alter table Jobsets add check ((type = 1) = (flake is not null)); +alter table JobsetEvals add column flake text;