Skip to content

Instantly share code, notes, and snippets.

@SodaDev
Last active February 3, 2021 16:15
Show Gist options
  • Save SodaDev/575fb977ef979f09ce63548b7369a9db to your computer and use it in GitHub Desktop.
Save SodaDev/575fb977ef979f09ce63548b7369a9db to your computer and use it in GitHub Desktop.
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