-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trigger function in scheduling_specification correctly updates spec r…
…evision
- Loading branch information
1 parent
afca30f
commit 6027ebc
Showing
5 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
deployment/hasura/migrations/AerieScheduler/11_fix_scheduling_spec_trigger/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
create or replace function increment_revision_on_goal_update() | ||
returns trigger | ||
security definer | ||
language plpgsql as $$begin | ||
with goals as ( | ||
select g.specification_id from scheduling_specification_goals as g | ||
where g.specification_id = new.id | ||
) | ||
update scheduling_specification set revision = revision + 1 | ||
where exists(select 1 from goals where specification_id = id); | ||
return new; | ||
end$$; | ||
|
||
call migrations.mark_migration_rolled_back('11'); |
14 changes: 14 additions & 0 deletions
14
deployment/hasura/migrations/AerieScheduler/11_fix_scheduling_spec_trigger/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
create or replace function increment_revision_on_goal_update() | ||
returns trigger | ||
security definer | ||
language plpgsql as $$begin | ||
with goals as ( | ||
select g.specification_id from scheduling_specification_goals as g | ||
where g.goal_id = new.id | ||
) | ||
update scheduling_specification set revision = revision + 1 | ||
where exists(select 1 from goals where specification_id = id); | ||
return new; | ||
end$$; | ||
|
||
call migrations.mark_migration_applied('11'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters