Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy the flake migration from the flake branch #713

Merged
merged 1 commit into from Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/lib/Hydra/Schema/JobsetEvals.pm
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
27 changes: 21 additions & 6 deletions src/lib/Hydra/Schema/Jobsets.pm
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 => [
Expand Down
13 changes: 10 additions & 3 deletions src/sql/hydra.sql
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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
);
Expand Down
7 changes: 7 additions & 0 deletions 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;