Last active
February 3, 2021 16:15
-
-
Save SodaDev/575fb977ef979f09ce63548b7369a9db 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 NEW_ROUTE; | |
CREATE TRIGGER NEW_ROUTE | |
AFTER INSERT | |
ON routes | |
FOR EACH ROW | |
BEGIN | |
CALL mysql.lambda_async( | |
'arn:aws:lambda:eu-west-1:XXXXXXXXXX:function:RDS-EVENTS-CONSUMER', | |
JSON_OBJECT('new', JSON_OBJECT( | |
'airportFrom', NEW.airportFrom, | |
'airportTo', NEW.airportTo, | |
'connectingAirport', NEW.connectingAirport, | |
'newRoute', NEW.newRoute is true, | |
'seasonalRoute', NEW.seasonalRoute is true, | |
'operator', NEW.operator, | |
'group', NEW.group, | |
'tags', NEW.tags, | |
'similarArrivalAirportCodes', NEW.similarArrivalAirportCodes, | |
'carrierCode', NEW.carrierCode) | |
) | |
); | |
end; | |
# Test insert | |
INSERT INTO flights.routes (airportFrom, airportTo, connectingAirport, newRoute, seasonalRoute, operator, `group`, tags, similarArrivalAirportCodes, carrierCode) | |
VALUES ('FOO', 'BAR', null, false, false, 'RYANAIR', 'CITY', '', '', 'FR'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment