-- Create trigger that fires on ANY task update
-- Replaces the old trg_task_fixed_update_visibility trigger
-- This trigger calls process_store_category_data, update_product_store_data, and process_store_metrics_set_based

-- First, drop the old trigger (if it exists)
DROP TRIGGER IF EXISTS trg_task_fixed_update_visibility ON task;

-- Create the new trigger
DROP TRIGGER IF EXISTS trg_task_update_process_metrics ON task;
CREATE TRIGGER trg_task_update_process_metrics
  AFTER UPDATE ON task
  FOR EACH ROW
  EXECUTE FUNCTION fn_task_update_process_metrics();

