-- ============================================================================
-- Database Triggers for SCM Microservice
-- ============================================================================

-- Trigger: Update timestamp for Invoice Adjustment Notes
DROP TRIGGER IF EXISTS trg_update_adjustment_note_timestamp ON trans.scm_invoice_adjustment_note;

CREATE TRIGGER trg_update_adjustment_note_timestamp
    BEFORE UPDATE ON trans.scm_invoice_adjustment_note
    FOR EACH ROW
    EXECUTE FUNCTION trans.update_adjustment_note_timestamp();

-- Trigger: Update timestamp for Trade Shipments
DROP TRIGGER IF EXISTS trigger_update_trade_shipment_updated_at ON trans.scm_trade_shipment;

CREATE TRIGGER trigger_update_trade_shipment_updated_at
    BEFORE UPDATE ON trans.scm_trade_shipment
    FOR EACH ROW
    EXECUTE FUNCTION trans.update_trade_shipment_updated_at();
