RunCommandLogs: add a uuid to each log entry

This commit is contained in:
Graham Christensen 2022-01-24 11:37:42 -05:00 committed by Cole Helbling
parent 3ae4b19d12
commit cf49a05ff5
3 changed files with 34 additions and 3 deletions

View file

@ -42,6 +42,12 @@ __PACKAGE__->table("runcommandlogs");
is_nullable: 0 is_nullable: 0
sequence: 'runcommandlogs_id_seq' sequence: 'runcommandlogs_id_seq'
=head2 uuid
data_type: 'uuid'
is_nullable: 0
size: 16
=head2 job_matcher =head2 job_matcher
data_type: 'text' data_type: 'text'
@ -98,6 +104,8 @@ __PACKAGE__->add_columns(
is_nullable => 0, is_nullable => 0,
sequence => "runcommandlogs_id_seq", sequence => "runcommandlogs_id_seq",
}, },
"uuid",
{ data_type => "uuid", is_nullable => 0, size => 16 },
"job_matcher", "job_matcher",
{ data_type => "text", is_nullable => 0 }, { data_type => "text", is_nullable => 0 },
"build_id", "build_id",
@ -130,6 +138,20 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id"); __PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<runcommandlogs_uuid_unique>
=over 4
=item * L</uuid>
=back
=cut
__PACKAGE__->add_unique_constraint("runcommandlogs_uuid_unique", ["uuid"]);
=head1 RELATIONS =head1 RELATIONS
=head2 build =head2 build
@ -148,8 +170,8 @@ __PACKAGE__->belongs_to(
); );
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-19 15:15:36 # Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-01-24 10:24:52
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9AIzlQl1RjRXrs9gQCZKVw # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZVpYU6k3d/k/nitjpdgf/A
use POSIX qw(WEXITSTATUS WIFEXITED WIFSIGNALED WTERMSIG); use POSIX qw(WEXITSTATUS WIFEXITED WIFSIGNALED WTERMSIG);
use Digest::SHA1 qw(sha1_hex); use Digest::SHA1 qw(sha1_hex);

View file

@ -568,6 +568,7 @@ create index IndexTaskRetriesOrdered on TaskRetries(retry_at asc);
-- 3. Update the end_time and exit_code when it completes -- 3. Update the end_time and exit_code when it completes
create table RunCommandLogs ( create table RunCommandLogs (
id serial primary key not null, id serial primary key not null,
uuid uuid not null,
job_matcher text not null, job_matcher text not null,
build_id integer not null, build_id integer not null,
-- TODO: evaluation_id integer not null, -- TODO: evaluation_id integer not null,
@ -599,7 +600,9 @@ create table RunCommandLogs (
constraint RunCommandLogs_end_time_has_start_time check ( constraint RunCommandLogs_end_time_has_start_time check (
-- If end time is not null, then end_time, exit_code, and core_dumped should not be null -- If end time is not null, then end_time, exit_code, and core_dumped should not be null
(end_time is null) or (start_time is not null) (end_time is null) or (start_time is not null)
) ),
-- The uuid should be actually unique.
constraint RunCommandLogs_uuid_unique unique(uuid)
-- Note: if exit_code is not null then signal and core_dumped must be null. -- Note: if exit_code is not null then signal and core_dumped must be null.
-- Similarly, if signal is not null then exit_code must be null and -- Similarly, if signal is not null then exit_code must be null and

6
src/sql/upgrade-81.sql Normal file
View file

@ -0,0 +1,6 @@
alter table runcommandlogs add column uuid uuid;
update runcommandlogs set uuid = gen_random_uuid() where uuid is null;
alter table runcommandlogs alter column uuid set not null;
alter table runcommandlogs add constraint RunCommandLogs_uuid_unique unique(uuid);
# the unique uuid constraint adds a unique, btree index, so we don't need to create out own:
# "runcommandlogs_uuid_unique" UNIQUE CONSTRAINT, btree (uuid)