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

Track when Merge Requests were last updated #1292

Merged
merged 1 commit into from
Jan 30, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
drop trigger set_timestamp on merge_request;
drop function merge_request_set_updated_at();
alter table merge_request drop column updated_at;

call migrations.mark_migration_rolled_back('36');
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
alter table merge_request add column updated_at timestamptz not null default now();

create function merge_request_set_updated_at()
returns trigger
security definer
language plpgsql as $$begin
new.updated_at = now();
return new;
end$$;

create trigger set_timestamp
before update or insert on merge_request
for each row
execute function merge_request_set_updated_at();

call migrations.mark_migration_applied('36');

1 change: 1 addition & 0 deletions merlin-server/sql/merlin/applied_migrations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ call migrations.mark_migration_applied('32');
call migrations.mark_migration_applied('33');
call migrations.mark_migration_applied('34');
call migrations.mark_migration_applied('35');
call migrations.mark_migration_applied('36');
14 changes: 14 additions & 0 deletions merlin-server/sql/merlin/tables/merge_request.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ create table merge_request(
status merge_request_status default 'pending',
requester_username text,
reviewer_username text,
updated_at timestamptz not null default now(),
constraint merge_request_requester_exists
foreign key (requester_username)
references metadata.users
Expand Down Expand Up @@ -39,3 +40,16 @@ comment on column merge_request.requester_username is e''
'The user who created this merge request.';
comment on column merge_request.reviewer_username is e''
'The user who reviews this merge request. Is empty until the request enters review.';

create function merge_request_set_updated_at()
returns trigger
security definer
language plpgsql as $$begin
new.updated_at = now();
return new;
end$$;

create trigger set_timestamp
before update or insert on merge_request
for each row
execute function merge_request_set_updated_at();
Loading