-- create the trigger

-- on insertion
DROP TRIGGER IF EXISTS extend_sentences_lists_add ;
delimiter |

CREATE TRIGGER extend_sentences_lists_add AFTER INSERT ON `sentences_sentences_lists`
FOR EACH ROW 

	UPDATE `sentences_lists` AS sl 
      SET sl.modified = NOW()
      WHERE sl.id = NEW.sentences_list_id
      LIMIT 1;


-- delete
DROP TRIGGER IF EXISTS extend_sentences_lists_delete |
CREATE TRIGGER extend_sentences_lists_delete AFTER DELETE ON `sentences_sentences_lists`
FOR EACH ROW 
	UPDATE `sentences_lists` AS sl 
      SET sl.modified = NOW()
      WHERE sl.id = OLD.sentences_list_id
      LIMIT 1;
|


delimiter ;

-- create the trigger

-- on insertion
DROP TRIGGER IF EXISTS extend_sentences_lists_add ;
delimiter |

CREATE TRIGGER extend_sentences_lists_add AFTER INSERT ON `sentences_sentences_lists`
FOR EACH ROW BEGIN
      UPDATE `sentences_lists` AS sl
      SET sl.modified = NOW()
      WHERE sl.id = NEW.sentences_list_id
      LIMIT 1;
END;


-- delete
DROP TRIGGER IF EXISTS extend_sentences_lists_delete |
CREATE TRIGGER extend_sentences_lists_delete AFTER DELETE ON `sentences_sentences_lists`
FOR EACH ROW BEGIN
      UPDATE `sentences_lists` AS sl
      SET sl.modified = NOW()
      WHERE sl.id = OLD.sentences_list_id
      LIMIT 1;
END;

|


delimiter ;

Work around trigger import/export bug
Work around trigger import/export bug

When the trigger is created without BEGIN/END around the FOR loop,
mysqldump produces a syntaxically invalid "CREATE TRIGGER" directive,
and mysql fails to import it with the following message :

ERROR 1064 (42000) at line 56: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '*/' at line 1

Note that this bug seems to be specific to MariaDB as I can’t
reproduce it on a pure MySQL database.
