Skip to content

Commit

Permalink
Fix "before delete on" trigger on Scheduling Specification Conditions
Browse files Browse the repository at this point in the history
If a "before" trigger returns `NULL`, the operation is cancelled, as per the Postgres Documentation (https://www.postgresql.org/docs/16/trigger-definition.html).
  • Loading branch information
Mythicaeda committed Jan 28, 2025
1 parent ab573c3 commit 294d992
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
create or replace function scheduler.increment_spec_revision_on_conditions_spec_delete()
returns trigger
security definer
language plpgsql as $$
begin
update scheduler.scheduling_specification
set revision = revision + 1
where id = new.specification_id;
return new;
end;
$$;
call migrations.mark_migration_rolled_back('13');
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
create or replace function scheduler.increment_spec_revision_on_conditions_spec_delete()
returns trigger
security definer
language plpgsql as $$
begin
update scheduler.scheduling_specification
set revision = revision + 1
where id = new.specification_id;
return old;
end;
$$;
call migrations.mark_migration_applied('13');
1 change: 1 addition & 0 deletions deployment/postgres-init-db/sql/applied_migrations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ call migrations.mark_migration_applied('9');
call migrations.mark_migration_applied('10');
call migrations.mark_migration_applied('11');
call migrations.mark_migration_applied('12');
call migrations.mark_migration_applied('13');
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ begin
update scheduler.scheduling_specification
set revision = revision + 1
where id = new.specification_id;
return new;
return old;
end;
$$;

Expand Down

0 comments on commit 294d992

Please sign in to comment.