-- ============================================================================
-- Add workflow_event_triggers entry for quotations
-- ============================================================================
-- This links database operations (insert/update) on quotations table 
-- to the workflow event that will trigger the workflow

INSERT INTO workflow_event_triggers (
    event_name,
    table_name,
    trigger_type,
    operations,
    field_map,
    form_id,
    isDeleted
) VALUES (
    'quotations.updated',           -- Must match workflow.trigger_event
    'quotations',                   -- Table to monitor
    'insert',                       -- Default type (will be overridden by operations)
    '["insert", "update"]',         -- Trigger on both insert and update
    '{"id": "quotation_id"}',       -- Map quotation_id to context.id
    NULL,                           -- No specific form required
    FALSE
) ON CONFLICT DO NOTHING;

-- Verify the trigger was created
SELECT * FROM workflow_event_triggers WHERE table_name = 'quotations';
