Allow Plan Bounds to be Changed#1833
Conversation
- Adds a trigger to cascade boundary changes - Allows snapshots to track and restore plan bounds
- This constraint is no longer necessary now that we have snapshot description to disambiguate identically-named snapshots
56a3c0d to
a4d6904
Compare
a4d6904 to
f4c256b
Compare
|
Todo: write a test that checks that the activity relative time gets updated to maintain absolute time when plan bounds change |
dandelany
left a comment
There was a problem hiding this comment.
Generally looks good - a few changes below. Hardest thing is figuring out to do with the cascading trigger problem mentioned below... @Mythicaeda will look into options
| create trigger increment_plan_revision_on_directive_update_trigger | ||
| after update on merlin.activity_directive | ||
| for each row | ||
| when (pg_trigger_depth() < 1) |
There was a problem hiding this comment.
Per review discussion, we are a bit nervous that preventing by depth is a "blunt instrument" that might have unintended consequences for other/future triggers. @Mythicaeda will look into other ways of targeting & preventing only the trigger we care about instead of any with depth > 1... If trigger relId or trigger tableName identifies it as coming from the plans table, we can use that to target
| from merlin.simulation sim_spec | ||
| where simulation_id = sim_spec.id | ||
| and sim_spec.plan_id = old.id; | ||
|
|
There was a problem hiding this comment.
Per discussion:
- we want to update sim bounds here (when updating plan bounds) - they are stored as absolute times
- if sim bounds match plan bounds before update - update them to match new plan bounds
- else:
- trim sim bounds so that neither begin or end of sim bounds is outside of plan bounds
- if sim bounds are entirely outside of plan bounds after trimming, just reset sim bounds to the new plan bounds
|
|
||
| -- Add not null argument to new columns | ||
| alter table merlin.plan_snapshot | ||
| alter column plan_start_time set not null, |
There was a problem hiding this comment.
We currently don't delete plan snapshots associated with a plan when the plan is deleted. As a result, if this migration is run on a deployment where "orphan" snapshots exist, these not null columns will be set to null and fail... @Mythicaeda will consider best solution
Description
Adds a trigger to the Plan table to cascade updates to plan bounds to dependent tables
- specifically:
activity_directive,simulation_dataset, andplan_dataset- simulation bounds are NOT automatically updated by this trigger
- a snapshot is automatically taken when this trigger fires
Adds columns to the Plan Snapshots table to track plan boundaries at the time of snapshot creation
Updates the "Update Plan Revision when Activity Directive is Updated" trigger to not fire if another trigger updates the
activity_directivetableActivity Directiveis from the new trigger on Plan. All other updates to the Activity Directive table are either from function calls (iecommit_merge,delete_activity_by_pk_reanchor_subtree) or via user GQL requestsVerification
TODO
Documentation
Future work