delimiter $$ CREATE TABLE `report` ( `id` varchar(36) NOT NULL, `reportgroup_id` varchar(36) DEFAULT NULL, `company` varchar(255) DEFAULT NULL, `address` varchar(255) DEFAULT NULL, `postalcode` varchar(255) DEFAULT NULL, `city` varchar(255) DEFAULT NULL, `country` varchar(255) DEFAULT NULL, `contact` varchar(255) DEFAULT NULL, `email` varchar(255) DEFAULT NULL, `phone` varchar(255) DEFAULT NULL, `additional` text, `productiontype` varchar(255) DEFAULT NULL, `productiontitle` varchar(255) DEFAULT NULL, `firstonairdate` datetime DEFAULT NULL, `reporter` int(10) DEFAULT NULL, `created` datetime DEFAULT NULL, `updated` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `FK_report_reportgroup` (`reportgroup_id`), KEY `reporter` (`reporter`), CONSTRAINT `FK_report_reportgroup` FOREIGN KEY (`reportgroup_id`) REFERENCES `reportgroup` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC$$ CREATE DEFINER=`tracker_prod`@`%` TRIGGER `trackerdatabase_production`.`SYM_ON_I_FOR_RPRT_WBPRD` AFTER INSERT ON `trackerdatabase_production`.`report` FOR EACH ROW begin if 1=1 and @sync_triggers_disabled is null then insert into trackerdatabase_production_synch.sym_data (table_name, event_type, trigger_hist_id, row_data, channel_id, transaction_id, source_node_id, external_data, create_time) values( 'report', 'I', 20, concat( if(new.`id` is null,'',concat('"',replace(replace(new.`id`,'\','\\'),'"','\"'),'"')),',', if(new.`reportgroup_id` is null,'',concat('"',replace(replace(new.`reportgroup_id`,'\','\\'),'"','\"'),'"')),',', if(new.`company` is null,'',concat('"',replace(replace(new.`company`,'\','\\'),'"','\"'),'"')),',', if(new.`address` is null,'',concat('"',replace(replace(new.`address`,'\','\\'),'"','\"'),'"')),',', if(new.`postalcode` is null,'',concat('"',replace(replace(new.`postalcode`,'\','\\'),'"','\"'),'"')),',', if(new.`city` is null,'',concat('"',replace(replace(new.`city`,'\','\\'),'"','\"'),'"')),',', if(new.`country` is null,'',concat('"',replace(replace(new.`country`,'\','\\'),'"','\"'),'"')),',', if(new.`contact` is null,'',concat('"',replace(replace(new.`contact`,'\','\\'),'"','\"'),'"')),',', if(new.`email` is null,'',concat('"',replace(replace(new.`email`,'\','\\'),'"','\"'),'"')),',', if(new.`phone` is null,'',concat('"',replace(replace(new.`phone`,'\','\\'),'"','\"'),'"')),',', if(new.`additional` is null,'',concat('"',replace(replace(new.`additional`,'\','\\'),'"','\"'),'"')),',', if(new.`productiontype` is null,'',concat('"',replace(replace(new.`productiontype`,'\','\\'),'"','\"'),'"')),',', if(new.`productiontitle` is null,'',concat('"',replace(replace(new.`productiontitle`,'\','\\'),'"','\"'),'"')),',', if(new.`firstonairdate` is null,'',concat('"',cast(new.`firstonairdate` as char),'"')),',', if(new.`reporter` is null,'',concat('"',cast(new.`reporter` as char),'"')),',', if(new.`created` is null,'',concat('"',cast(new.`created` as char),'"')),',', if(new.`updated` is null,'',concat('"',cast(new.`updated` as char),'"')) ), 'default', trackerdatabase_production_synch.sym_transaction_id(), @sync_node_disabled, null, CURRENT_TIMESTAMP ); end if; end $$ CREATE DEFINER=`tracker_prod`@`%` TRIGGER `trackerdatabase_production`.`SYM_ON_U_FOR_RPRT_WBPRD` AFTER UPDATE ON `trackerdatabase_production`.`report` FOR EACH ROW begin DECLARE var_row_data mediumtext character set utf8; DECLARE var_old_data mediumtext character set utf8; if 1=1 and @sync_triggers_disabled is null then set var_row_data = concat( if(new.`id` is null,'',concat('"',replace(replace(new.`id`,'\','\\'),'"','\"'),'"')),',', if(new.`reportgroup_id` is null,'',concat('"',replace(replace(new.`reportgroup_id`,'\','\\'),'"','\"'),'"')),',', if(new.`company` is null,'',concat('"',replace(replace(new.`company`,'\','\\'),'"','\"'),'"')),',', if(new.`address` is null,'',concat('"',replace(replace(new.`address`,'\','\\'),'"','\"'),'"')),',', if(new.`postalcode` is null,'',concat('"',replace(replace(new.`postalcode`,'\','\\'),'"','\"'),'"')),',', if(new.`city` is null,'',concat('"',replace(replace(new.`city`,'\','\\'),'"','\"'),'"')),',', if(new.`country` is null,'',concat('"',replace(replace(new.`country`,'\','\\'),'"','\"'),'"')),',', if(new.`contact` is null,'',concat('"',replace(replace(new.`contact`,'\','\\'),'"','\"'),'"')),',', if(new.`email` is null,'',concat('"',replace(replace(new.`email`,'\','\\'),'"','\"'),'"')),',', if(new.`phone` is null,'',concat('"',replace(replace(new.`phone`,'\','\\'),'"','\"'),'"')),',', if(new.`additional` is null,'',concat('"',replace(replace(new.`additional`,'\','\\'),'"','\"'),'"')),',', if(new.`productiontype` is null,'',concat('"',replace(replace(new.`productiontype`,'\','\\'),'"','\"'),'"')),',', if(new.`productiontitle` is null,'',concat('"',replace(replace(new.`productiontitle`,'\','\\'),'"','\"'),'"')),',', if(new.`firstonairdate` is null,'',concat('"',cast(new.`firstonairdate` as char),'"')),',', if(new.`reporter` is null,'',concat('"',cast(new.`reporter` as char),'"')),',', if(new.`created` is null,'',concat('"',cast(new.`created` as char),'"')),',', if(new.`updated` is null,'',concat('"',cast(new.`updated` as char),'"'))); set var_old_data = concat( if(old.`id` is null,'',concat('"',replace(replace(old.`id`,'\','\\'),'"','\"'),'"')),',', if(old.`reportgroup_id` is null,'',concat('"',replace(replace(old.`reportgroup_id`,'\','\\'),'"','\"'),'"')),',', if(old.`company` is null,'',concat('"',replace(replace(old.`company`,'\','\\'),'"','\"'),'"')),',', if(old.`address` is null,'',concat('"',replace(replace(old.`address`,'\','\\'),'"','\"'),'"')),',', if(old.`postalcode` is null,'',concat('"',replace(replace(old.`postalcode`,'\','\\'),'"','\"'),'"')),',', if(old.`city` is null,'',concat('"',replace(replace(old.`city`,'\','\\'),'"','\"'),'"')),',', if(old.`country` is null,'',concat('"',replace(replace(old.`country`,'\','\\'),'"','\"'),'"')),',', if(old.`contact` is null,'',concat('"',replace(replace(old.`contact`,'\','\\'),'"','\"'),'"')),',', if(old.`email` is null,'',concat('"',replace(replace(old.`email`,'\','\\'),'"','\"'),'"')),',', if(old.`phone` is null,'',concat('"',replace(replace(old.`phone`,'\','\\'),'"','\"'),'"')),',', if(old.`additional` is null,'',concat('"',replace(replace(old.`additional`,'\','\\'),'"','\"'),'"')),',', if(old.`productiontype` is null,'',concat('"',replace(replace(old.`productiontype`,'\','\\'),'"','\"'),'"')),',', if(old.`productiontitle` is null,'',concat('"',replace(replace(old.`productiontitle`,'\','\\'),'"','\"'),'"')),',', if(old.`firstonairdate` is null,'',concat('"',cast(old.`firstonairdate` as char),'"')),',', if(old.`reporter` is null,'',concat('"',cast(old.`reporter` as char),'"')),',', if(old.`created` is null,'',concat('"',cast(old.`created` as char),'"')),',', if(old.`updated` is null,'',concat('"',cast(old.`updated` as char),'"'))); if 1=1 then insert into trackerdatabase_production_synch.sym_data (table_name, event_type, trigger_hist_id, pk_data, row_data, old_data, channel_id, transaction_id, source_node_id, external_data, create_time) values( 'report', 'U', 20, concat( if(old.`id` is null,'',concat('"',replace(replace(old.`id`,'\','\\'),'"','\"'),'"')) ), var_row_data, var_old_data, 'default', trackerdatabase_production_synch.sym_transaction_id(), @sync_node_disabled, null, CURRENT_TIMESTAMP ); end if; end if; end $$ CREATE DEFINER=`tracker_prod`@`%` TRIGGER `trackerdatabase_production`.`SYM_ON_D_FOR_RPRT_WBPRD` AFTER DELETE ON `trackerdatabase_production`.`report` FOR EACH ROW begin if 1=1 and @sync_triggers_disabled is null then insert into trackerdatabase_production_synch.sym_data (table_name, event_type, trigger_hist_id, pk_data, old_data, channel_id, transaction_id, source_node_id, external_data, create_time) values( 'report', 'D', 20, concat( if(old.`id` is null,'',concat('"',replace(replace(old.`id`,'\','\\'),'"','\"'),'"')) ), concat( if(old.`id` is null,'',concat('"',replace(replace(old.`id`,'\','\\'),'"','\"'),'"')),',', if(old.`reportgroup_id` is null,'',concat('"',replace(replace(old.`reportgroup_id`,'\','\\'),'"','\"'),'"')),',', if(old.`company` is null,'',concat('"',replace(replace(old.`company`,'\','\\'),'"','\"'),'"')),',', if(old.`address` is null,'',concat('"',replace(replace(old.`address`,'\','\\'),'"','\"'),'"')),',', if(old.`postalcode` is null,'',concat('"',replace(replace(old.`postalcode`,'\','\\'),'"','\"'),'"')),',', if(old.`city` is null,'',concat('"',replace(replace(old.`city`,'\','\\'),'"','\"'),'"')),',', if(old.`country` is null,'',concat('"',replace(replace(old.`country`,'\','\\'),'"','\"'),'"')),',', if(old.`contact` is null,'',concat('"',replace(replace(old.`contact`,'\','\\'),'"','\"'),'"')),',', if(old.`email` is null,'',concat('"',replace(replace(old.`email`,'\','\\'),'"','\"'),'"')),',', if(old.`phone` is null,'',concat('"',replace(replace(old.`phone`,'\','\\'),'"','\"'),'"')),',', if(old.`additional` is null,'',concat('"',replace(replace(old.`additional`,'\','\\'),'"','\"'),'"')),',', if(old.`productiontype` is null,'',concat('"',replace(replace(old.`productiontype`,'\','\\'),'"','\"'),'"')),',', if(old.`productiontitle` is null,'',concat('"',replace(replace(old.`productiontitle`,'\','\\'),'"','\"'),'"')),',', if(old.`firstonairdate` is null,'',concat('"',cast(old.`firstonairdate` as char),'"')),',', if(old.`reporter` is null,'',concat('"',cast(old.`reporter` as char),'"')),',', if(old.`created` is null,'',concat('"',cast(old.`created` as char),'"')),',', if(old.`updated` is null,'',concat('"',cast(old.`updated` as char),'"')) ), 'default', trackerdatabase_production_synch.sym_transaction_id(), @sync_node_disabled, null, CURRENT_TIMESTAMP ); end if; end $$