Description:
I'm creating some triggers for Tables. If I'm sychronizing with live db there are allways differences between model and db, although the sql of the triggers are equal on db and model. But he is reformating the sql at creating the trigger on the live db.
ON MODEL:
CREATE TRIGGER `famberg_maindb`.`acc_campaigns_after_update` AFTER UPDATE ON `famberg_maindb`.`acc_campaigns`
FOR EACH ROW
BEGIN
INSERT INTO sys_changes SET sys_changes.table = 'acc_campaigns', sys_changes.user = CURRENT_USER(), sys_changes.time = NOW(), operation = "update", primary_key = NEW.campaign_id;
END$$
CREATING ON DB:
CREATE <---- removing spaces and replacing with line breaks
DEFINER=`root`@`%` <---- adding DEFINER Keyword.
TRIGGER `famberg_maindb`.`acc_campaigns_after_update`
AFTER UPDATE ON `famberg_maindb`.`acc_campaigns`
FOR EACH ROW
BEGIN
INSERT INTO sys_changes SET sys_changes.table = 'acc_campaigns', sys_changes.user = CURRENT_USER(), sys_changes.time = NOW(), operation = "update", primary_key = NEW.campaign_id;
END$$
It's enough if you put a space after a line of the sql code of the trigger for detecting differences.
Because of this reformating he sychronize triggers everytime I sychronizing the Model with Database.
How to repeat:
Create a Trigger on Table with follow SQL:
-- Trigger DDL Statements
DELIMITER $$
USE `famberg_maindb`$$
CREATE(insert a space before line break or don't use line break, only space)
DEFINER=`root`@`%`
TRIGGER `database`.`triggername`
AFTER UPDATE ON `databaseb`.`table`
FOR EACH ROW
BEGIN
statement;
END$$
Now Sychronize Model with Live DB. He will synchronzie allways you start.
Suggested fix:
You should reformat the Trigger SQL at saving in Model or reformat before compare for sychroniziation. Or just use a more common compare.