Skip to content

Commit

Permalink
Handles the case where goals are deleted from a spec before procedura…
Browse files Browse the repository at this point in the history
…l scheduling migration is applied
  • Loading branch information
skovati committed Nov 12, 2024
1 parent f271123 commit ec6c54f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions deployment/hasura/migrations/Aerie/10_procedural_scheduling/up.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
begin;

alter table scheduler.scheduling_specification_goals
add column goal_invocation_id integer generated by default as identity,

Expand Down Expand Up @@ -29,6 +31,11 @@ from scheduler.scheduling_request as sr
where sr.analysis_id = sga.analysis_id
and sga.goal_id = ssg.goal_id;

-- v3.1.1 migration patch addition
update scheduler.scheduling_goal_analysis
set goal_invocation_id = -1 * goal_id
where goal_invocation_id is null;

alter table scheduler.scheduling_goal_analysis
-- explictly set not null before PKing
alter column goal_invocation_id set not null,
Expand All @@ -53,6 +60,11 @@ from scheduler.scheduling_request as sr
where sr.analysis_id = sgaca.analysis_id
and sgaca.goal_id = ssg.goal_id;

-- v3.1.1 migration patch addition
update scheduler.scheduling_goal_analysis_created_activities
set goal_invocation_id = -1 * goal_id
where goal_invocation_id is null;

alter table scheduler.scheduling_goal_analysis_created_activities
drop column goal_id,
drop column goal_revision,
Expand Down Expand Up @@ -85,6 +97,11 @@ from scheduler.scheduling_request as sr
where sr.analysis_id = sgasa.analysis_id
and sgasa.goal_id = ssg.goal_id;

-- v3.1.1 migration patch addition
update scheduler.scheduling_goal_analysis_satisfying_activities
set goal_invocation_id = -1 * goal_id
where goal_invocation_id is null;

alter table scheduler.scheduling_goal_analysis_satisfying_activities
drop column goal_id,
drop column goal_revision,
Expand Down Expand Up @@ -151,3 +168,4 @@ comment on column scheduler.scheduling_goal_analysis.arguments is e''
'Follows scheduler.scheduling_goal_definition.parameter_schema.';

call migrations.mark_migration_applied('10');
commit;

0 comments on commit ec6c54f

Please sign in to comment.