Files
aowow/setup/tools/trigger_example.txt
Sarjuuk b5c2f7a296 Git/Misc
* force text files eol to \n
2024-07-31 00:50:46 +02:00

32 lines
786 B
Plaintext

CREATE TABLE `aowow_sync` (
`table` VARCHAR(50) NOT NULL,
`entry` INT NOT NULL,
`action` TINYINT NOT NULL COMMENT '0:delete; 1:insert; 2:update'
) COLLATE='utf8_general_ci' ENGINE=MyISAM;
delimiter |
CREATE TRIGGER aowow_sync_<table>_delete BEFORE DELETE ON <table>
FOR EACH ROW
BEGIN
REPLACE INTO aowow_sync (`table`, `entry`, `action`) VALUES ('<table>', OLD.entry, 0);
END;
|
CREATE TRIGGER aowow_sync_<table>_insert AFTER INSERT ON <table>
FOR EACH ROW
BEGIN
REPLACE INTO aowow_sync (`table`, `entry`, `action`) VALUES ('<table>', NEW.entry, 1);
END;
|
CREATE TRIGGER aowow_sync_<table>_update AFTER UPDATE ON <table>
FOR EACH ROW
BEGIN
REPLACE INTO aowow_sync (`table`, `entry`, `action`) VALUES ('<table>', NEW.entry, 2);
END;
|
delimiter ;