Created
February 2, 2021 22:04
-
-
Save SodaDev/3d806764c09431a8dd8a54117e7f48a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TRIGGER IF EXISTS DELETED_ROUTE; | |
CREATE TRIGGER DELETED_ROUTE | |
AFTER DELETE | |
ON routes | |
FOR EACH ROW | |
BEGIN | |
CALL mysql.lambda_async( | |
'arn:aws:lambda:eu-west-1:XXXXXXXXXX:function:RDS-EVENTS-CONSUMER', | |
JSON_OBJECT( | |
'old', JSON_OBJECT( | |
'airportFrom', OLD.airportFrom, | |
'airportTo', OLD.airportTo, | |
'connectingAirport', OLD.connectingAirport, | |
'newRoute', OLD.newRoute is true, | |
'seasonalRoute', OLD.seasonalRoute is true, | |
'operator', OLD.operator, | |
'group', OLD.group, | |
'tags', OLD.tags, | |
'similarArrivalAirportCodes', OLD.similarArrivalAirportCodes, | |
'carrierCode', OLD.carrierCode) | |
) | |
); | |
end; | |
# Test delete | |
DELETE FROM flights.routes WHERE airportFrom = 'FOO' AND airportTo = 'BAR'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment