init.sql 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  1. -- 创建消息表
  2. drop table if exists lucene$message;
  3. create table lucene$message(
  4. me_id bigint not null primary key auto_increment,
  5. me_table_name varchar(64) not null,
  6. me_method_type varchar(6) not null,
  7. me_data_id int not null,
  8. me_data text,
  9. me_priority int default 0,
  10. me_retry_count int default 0,
  11. me_create_time datetime not null
  12. );
  13. -- 创建消息历史表
  14. drop table if exists lucene$message_history;
  15. create table lucene$message_history(
  16. mh_id bigint not null primary key auto_increment,
  17. mh_dequeue_time datetime not null,
  18. me_id bigint not null,
  19. me_table_name varchar(64) not null,
  20. me_method_type varchar(6) not null,
  21. me_data_id int not null,
  22. me_data text,
  23. me_priority int default 0,
  24. me_create_time datetime not null
  25. );
  26. -- 创建存储过程 入队消息
  27. drop procedure if exists enqueue_lucene_message;
  28. delimiter $$
  29. create procedure enqueue_lucene_message(in v_table_name varchar(64), v_method_type varchar(6), v_data_id int, v_data text, v_priority int)
  30. begin
  31. insert into lucene$message (me_table_name, me_method_type, me_data_id, me_data, me_priority, me_create_time) values(v_table_name, v_method_type, v_data_id, v_data, v_priority, sysdate());
  32. end;$$
  33. delimiter ;
  34. -- 创建存储过程 出队消息
  35. drop procedure if exists dequeue_lucene_message;
  36. delimiter $$
  37. create procedure dequeue_lucene_message(in v_id bigint)
  38. begin
  39. insert into lucene$message_history (mh_dequeue_time, me_id, me_table_name, me_method_type, me_data_id, me_data, me_priority, me_create_time) select sysdate(), me_id, me_table_name, me_method_type, me_data_id, me_data, me_priority, me_create_time from lucene$message where me_id = v_id;
  40. delete from lucene$message where me_id = v_id;
  41. end;$$
  42. delimiter ;
  43. -- ----------------------------
  44. -- Triggers structure for table product$brand
  45. -- ----------------------------
  46. DROP TRIGGER IF EXISTS `lucene_brand_i`;
  47. delimiter ;;
  48. CREATE DEFINER = `root`@`%` TRIGGER `lucene_brand_i` AFTER INSERT ON `product$brand` FOR EACH ROW begin
  49. declare v_table_name varchar(64) default 'product$brand';
  50. declare v_method_type varchar(6) default 'insert';
  51. declare v_data_id int;
  52. declare v_data text default null;
  53. declare v_priority int default 1;
  54. set v_data_id=new.br_id;
  55. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  56. end
  57. ;;
  58. delimiter ;
  59. -- ----------------------------
  60. -- Triggers structure for table product$brand
  61. -- ----------------------------
  62. DROP TRIGGER IF EXISTS `lucene_brand_u`;
  63. delimiter ;;
  64. CREATE DEFINER = `root`@`%` TRIGGER `lucene_brand_u` AFTER UPDATE ON `product$brand` FOR EACH ROW begin
  65. declare v_table_name varchar(64) default 'product$brand';
  66. declare v_method_type varchar(6) default 'update';
  67. declare v_data_id int;
  68. declare v_data text default null;
  69. declare v_priority int default 1;
  70. set v_data_id=old.br_id;
  71. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  72. end
  73. ;;
  74. delimiter ;
  75. -- ----------------------------
  76. -- Triggers structure for table product$brand
  77. -- ----------------------------
  78. DROP TRIGGER IF EXISTS `lucene_brand_d`;
  79. delimiter ;;
  80. CREATE DEFINER = `root`@`%` TRIGGER `lucene_brand_d` AFTER DELETE ON `product$brand` FOR EACH ROW begin
  81. declare v_table_name varchar(64) default 'product$brand';
  82. declare v_method_type varchar(6) default 'delete';
  83. declare v_data_id int;
  84. declare v_data text default null;
  85. declare v_priority int default 1;
  86. set v_data_id=old.br_id;
  87. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  88. end
  89. ;;
  90. delimiter ;
  91. -- ----------------------------
  92. -- Triggers structure for table product$component
  93. -- ----------------------------
  94. DROP TRIGGER IF EXISTS `lucene_component_i`;
  95. delimiter ;;
  96. CREATE DEFINER = `root`@`%` TRIGGER `lucene_component_i` AFTER INSERT ON `product$component` FOR EACH ROW begin
  97. declare v_table_name varchar(64) default 'product$component';
  98. declare v_method_type varchar(6) default 'insert';
  99. declare v_data_id int;
  100. declare v_data text default null;
  101. declare v_priority int default 0;
  102. set v_data_id=new.cmp_id;
  103. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  104. set v_table_name='v$product$cmpgoods';
  105. set v_data='cmpId';
  106. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  107. end
  108. ;;
  109. delimiter ;
  110. -- ----------------------------
  111. -- Triggers structure for table product$component
  112. -- ----------------------------
  113. DROP TRIGGER IF EXISTS `lucene_component_u`;
  114. delimiter ;;
  115. CREATE DEFINER = `root`@`%` TRIGGER `lucene_component_u` AFTER UPDATE ON `product$component` FOR EACH ROW begin
  116. declare v_table_name varchar(64) default 'product$component';
  117. declare v_method_type varchar(6) default 'update';
  118. declare v_data_id int;
  119. declare v_data text default null;
  120. declare v_priority int default 0;
  121. set v_data_id=old.cmp_id;
  122. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  123. set v_table_name='v$product$cmpgoods';
  124. set v_data='cmpId';
  125. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  126. end
  127. ;;
  128. delimiter ;
  129. -- ----------------------------
  130. -- Triggers structure for table product$component
  131. -- ----------------------------
  132. DROP TRIGGER IF EXISTS `lucene_component_d`;
  133. delimiter ;;
  134. CREATE DEFINER = `root`@`%` TRIGGER `lucene_component_d` AFTER DELETE ON `product$component` FOR EACH ROW begin
  135. declare v_table_name varchar(64) default 'product$component';
  136. declare v_method_type varchar(6) default 'delete';
  137. declare v_data_id int;
  138. declare v_data text default null;
  139. declare v_priority int default 0;
  140. set v_data_id=old.cmp_id;
  141. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  142. set v_table_name='v$product$cmpgoods';
  143. set v_data='cmpId';
  144. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  145. end
  146. ;;
  147. delimiter ;
  148. -- ----------------------------
  149. -- Triggers structure for table product$kind
  150. -- ----------------------------
  151. DROP TRIGGER IF EXISTS `lucene_kind_i`;
  152. delimiter ;;
  153. CREATE DEFINER = `root`@`%` TRIGGER `lucene_kind_i` AFTER INSERT ON `product$kind` FOR EACH ROW begin
  154. declare v_table_name varchar(64) default 'product$kind';
  155. declare v_method_type varchar(6) default 'insert';
  156. declare v_data_id int;
  157. declare v_data text default null;
  158. declare v_priority int default 1;
  159. set v_data_id=new.ki_id;
  160. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  161. end
  162. ;;
  163. delimiter ;
  164. -- ----------------------------
  165. -- Triggers structure for table product$kind
  166. -- ----------------------------
  167. DROP TRIGGER IF EXISTS `lucene_kind_u`;
  168. delimiter ;;
  169. CREATE DEFINER = `root`@`%` TRIGGER `lucene_kind_u` AFTER UPDATE ON `product$kind` FOR EACH ROW begin
  170. declare v_table_name varchar(64) default 'product$kind';
  171. declare v_method_type varchar(6) default 'update';
  172. declare v_data_id int;
  173. declare v_data text default null;
  174. declare v_priority int default 1;
  175. set v_data_id=old.ki_id;
  176. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  177. end
  178. ;;
  179. delimiter ;
  180. -- ----------------------------
  181. -- Triggers structure for table product$kind
  182. -- ----------------------------
  183. DROP TRIGGER IF EXISTS `lucene_kind_d`;
  184. delimiter ;;
  185. CREATE DEFINER = `root`@`%` TRIGGER `lucene_kind_d` AFTER DELETE ON `product$kind` FOR EACH ROW begin
  186. declare v_table_name varchar(64) default 'product$kind';
  187. declare v_method_type varchar(6) default 'delete';
  188. declare v_data_id int;
  189. declare v_data text default null;
  190. declare v_priority int default 1;
  191. set v_data_id=old.ki_id;
  192. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  193. end
  194. ;;
  195. delimiter ;
  196. -- ----------------------------
  197. -- Triggers structure for table product$propertyvalue
  198. -- ----------------------------
  199. DROP TRIGGER IF EXISTS `lucene_propertyvalue_i`;
  200. delimiter ;;
  201. CREATE DEFINER = `root`@`%` TRIGGER `lucene_propertyvalue_i` AFTER INSERT ON `product$propertyvalue` FOR EACH ROW begin
  202. declare v_table_name varchar(64) default 'product$component';
  203. declare v_method_type varchar(6) default 'update';
  204. declare v_data_id int;
  205. declare v_data text default null;
  206. declare v_priority int default 0;
  207. set v_data_id=new.pv_componentid;
  208. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  209. end
  210. ;;
  211. delimiter ;
  212. -- ----------------------------
  213. -- Triggers structure for table product$propertyvalue
  214. -- ----------------------------
  215. DROP TRIGGER IF EXISTS `lucene_propertyvalue_u`;
  216. delimiter ;;
  217. CREATE DEFINER = `root`@`%` TRIGGER `lucene_propertyvalue_u` AFTER UPDATE ON `product$propertyvalue` FOR EACH ROW begin
  218. declare v_table_name varchar(64) default 'product$component';
  219. declare v_method_type varchar(6) default 'update';
  220. declare v_data_id int;
  221. declare v_data text default null;
  222. declare v_priority int default 0;
  223. set v_data_id=old.pv_componentid;
  224. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  225. end
  226. ;;
  227. delimiter ;
  228. -- ----------------------------
  229. -- Triggers structure for table product$propertyvalue
  230. -- ----------------------------
  231. DROP TRIGGER IF EXISTS `lucene_propertyvalue_d`;
  232. delimiter ;;
  233. CREATE DEFINER = `root`@`%` TRIGGER `lucene_propertyvalue_d` AFTER DELETE ON `product$propertyvalue` FOR EACH ROW begin
  234. declare v_table_name varchar(64) default 'product$component';
  235. declare v_method_type varchar(6) default 'update';
  236. declare v_data_id int;
  237. declare v_data text default null;
  238. declare v_priority int default 0;
  239. set v_data_id=old.pv_componentid;
  240. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  241. end
  242. ;;
  243. delimiter ;
  244. -- ----------------------------
  245. -- Triggers structure for table product$pcb
  246. -- ----------------------------
  247. DROP TRIGGER IF EXISTS `lucene_pcb_i`;
  248. delimiter ;;
  249. CREATE DEFINER = `root`@`%` TRIGGER `lucene_pcb_i` AFTER INSERT ON `product$pcb` FOR EACH ROW begin
  250. declare v_table_name varchar(64) default 'pcb_goods';
  251. declare v_method_type varchar(6) default 'insert';
  252. declare v_data_id int;
  253. declare v_data text default 'pcbId';
  254. declare v_priority int default 0;
  255. set v_data_id=new.pcb_id;
  256. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  257. end
  258. ;;
  259. delimiter ;
  260. -- ----------------------------
  261. -- Triggers structure for table product$pcb
  262. -- ----------------------------
  263. DROP TRIGGER IF EXISTS `lucene_pcb_u`;
  264. delimiter ;;
  265. CREATE DEFINER = `root`@`%` TRIGGER `lucene_pcb_u` AFTER UPDATE ON `product$pcb` FOR EACH ROW begin
  266. declare v_table_name varchar(64) default 'pcb_goods';
  267. declare v_method_type varchar(6) default 'update';
  268. declare v_data_id int;
  269. declare v_data text default 'pcbId';
  270. declare v_priority int default 0;
  271. set v_data_id=old.pcb_id;
  272. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  273. end
  274. ;;
  275. delimiter ;
  276. -- ----------------------------
  277. -- Triggers structure for table product$pcb
  278. -- ----------------------------
  279. DROP TRIGGER IF EXISTS `lucene_pcb_d`;
  280. delimiter ;;
  281. CREATE DEFINER = `root`@`%` TRIGGER `lucene_pcb_d` AFTER DELETE ON `product$pcb` FOR EACH ROW begin
  282. declare v_table_name varchar(64) default 'pcb_goods';
  283. declare v_method_type varchar(6) default 'delete';
  284. declare v_data_id int;
  285. declare v_data text default 'pcbId';
  286. declare v_priority int default 0;
  287. set v_data_id=old.pcb_id;
  288. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  289. end
  290. ;;
  291. delimiter ;
  292. -- ----------------------------
  293. -- Triggers structure for table trade$goods
  294. -- ----------------------------
  295. DROP TRIGGER IF EXISTS `lucene_trade_goods_i`;
  296. delimiter ;;
  297. CREATE DEFINER = `root`@`%` TRIGGER `lucene_trade_goods_i` AFTER INSERT ON `trade$goods` FOR EACH ROW begin
  298. declare v_table_name varchar(64) default 'v$product$cmpgoods';
  299. declare v_method_type varchar(6) default 'insert';
  300. declare v_data_id int;
  301. declare v_data text default 'goId';
  302. declare v_priority int default 1;
  303. if new.cmp_uuid is not null then
  304. set v_data='cmpId';
  305. select cmp_id into v_data_id from product$component where cmp_uuid=new.cmp_uuid;
  306. if v_data_id is null then
  307. set v_data=concat('cmp_uuid 没有关联的器件:', new.cmp_uuid);
  308. set v_data_id=new.go_id;
  309. end if;
  310. else
  311. set v_data_id=new.go_id;
  312. end if;
  313. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  314. set v_table_name='pcb_goods';
  315. if new.go_productid is not null then
  316. set v_data='pcbId';
  317. set v_data_id = null;
  318. select pcb_id into v_data_id from product$pcb where pcb_productid=new.go_productid;
  319. if v_data_id is null then
  320. set v_data=concat('go_productid 没有关联的 PCB:', new.go_productid);
  321. set v_data_id=new.go_id;
  322. end if;
  323. else
  324. set v_data_id=new.go_id;
  325. end if;
  326. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  327. end
  328. ;;
  329. delimiter ;
  330. -- ----------------------------
  331. -- Triggers structure for table trade$goods
  332. -- ----------------------------
  333. DROP TRIGGER IF EXISTS `lucene_trade_goods_u`;
  334. delimiter ;;
  335. CREATE DEFINER = `root`@`%` TRIGGER `lucene_trade_goods_u` AFTER UPDATE ON `trade$goods` FOR EACH ROW begin
  336. declare v_table_name varchar(64) default 'v$product$cmpgoods';
  337. declare v_method_type varchar(6) default 'update';
  338. declare v_data_id int;
  339. declare v_data text default 'goId';
  340. declare v_priority int default 0;
  341. if old.cmp_uuid is not null then
  342. set v_data='cmpId';
  343. select cmp_id into v_data_id from product$component where cmp_uuid=old.cmp_uuid;
  344. if v_data_id is null then
  345. set v_data=concat('cmp_uuid 没有关联的器件:', old.cmp_uuid);
  346. set v_data_id=old.go_id;
  347. end if;
  348. else
  349. set v_data_id=old.go_id;
  350. end if;
  351. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  352. set v_table_name='pcb_goods';
  353. if old.go_productid is not null then
  354. set v_data='pcbId';
  355. set v_data_id = null;
  356. select pcb_id into v_data_id from product$pcb where pcb_productid=old.go_productid;
  357. if v_data_id is null then
  358. set v_data=concat('go_productid 没有关联的 PCB:', old.go_productid);
  359. set v_data_id=old.go_id;
  360. end if;
  361. else
  362. set v_data_id=old.go_id;
  363. end if;
  364. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  365. end
  366. ;;
  367. delimiter ;
  368. -- ----------------------------
  369. -- Triggers structure for table trade$goods
  370. -- ----------------------------
  371. DROP TRIGGER IF EXISTS `lucene_trade_goods_d`;
  372. delimiter ;;
  373. CREATE DEFINER = `root`@`%` TRIGGER `lucene_trade_goods_d` AFTER DELETE ON `trade$goods` FOR EACH ROW begin
  374. declare v_table_name varchar(64) default 'v$product$cmpgoods';
  375. declare v_method_type varchar(6) default 'delete';
  376. declare v_data_id int;
  377. declare v_data text default 'goId';
  378. declare v_priority int default 0;
  379. if old.cmp_uuid is not null then
  380. set v_data='cmpId';
  381. select cmp_id into v_data_id from product$component where cmp_uuid=old.cmp_uuid;
  382. if v_data_id is null then
  383. set v_data=concat('cmp_uuid 没有关联的器件:', old.cmp_uuid);
  384. set v_data_id=old.go_id;
  385. end if;
  386. else
  387. set v_data_id=old.go_id;
  388. end if;
  389. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  390. set v_table_name='pcb_goods';
  391. if old.go_productid is not null then
  392. set v_data='pcbId';
  393. set v_data_id = null;
  394. select pcb_id into v_data_id from product$pcb where pcb_productid=old.go_productid;
  395. if v_data_id is null then
  396. set v_data=concat('go_productid 没有关联的 PCB:', old.go_productid);
  397. set v_data_id=old.go_id;
  398. end if;
  399. else
  400. set v_data_id=old.go_id;
  401. end if;
  402. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  403. end
  404. ;;
  405. delimiter ;
  406. -- ----------------------------
  407. -- Triggers structure for table trade$invoice_fmor
  408. -- ----------------------------
  409. DROP TRIGGER IF EXISTS `lucene_order_inv_i`;
  410. delimiter ;;
  411. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_inv_i` AFTER INSERT ON `trade$invoice_fmor` FOR EACH ROW begin
  412. declare v_table_name varchar(64) default 'trade$invoice_fmor';
  413. declare v_method_type varchar(6) default 'insert';
  414. declare v_data_id int;
  415. declare v_data text default null;
  416. declare v_priority int default 1;
  417. set v_data_id=new.id;
  418. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  419. end
  420. ;;
  421. delimiter ;
  422. -- ----------------------------
  423. -- Triggers structure for table trade$invoice_fmor
  424. -- ----------------------------
  425. DROP TRIGGER IF EXISTS `lucene_order_inv_u`;
  426. delimiter ;;
  427. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_inv_u` AFTER UPDATE ON `trade$invoice_fmor` FOR EACH ROW begin
  428. declare v_table_name varchar(64) default 'trade$invoice_fmor';
  429. declare v_method_type varchar(6) default 'update';
  430. declare v_data_id int;
  431. declare v_data text default null;
  432. declare v_priority int default 1;
  433. set v_data_id=old.id;
  434. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  435. end
  436. ;;
  437. delimiter ;
  438. -- ----------------------------
  439. -- Triggers structure for table trade$invoice_fmor
  440. -- ----------------------------
  441. DROP TRIGGER IF EXISTS `lucene_order_inv_d`;
  442. delimiter ;;
  443. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_inv_d` AFTER DELETE ON `trade$invoice_fmor` FOR EACH ROW begin
  444. declare v_table_name varchar(64) default 'trade$invoice_fmor';
  445. declare v_method_type varchar(6) default 'delete';
  446. declare v_data_id int;
  447. declare v_data text default null;
  448. declare v_priority int default 1;
  449. set v_data_id=old.id;
  450. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  451. end
  452. ;;
  453. delimiter ;
  454. -- ----------------------------
  455. -- Triggers structure for table trade$invoice_fmor_dt
  456. -- ----------------------------
  457. DROP TRIGGER IF EXISTS `lucene_order_inv_dt_i`;
  458. delimiter ;;
  459. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_inv_dt_i` AFTER INSERT ON `trade$invoice_fmor_dt` FOR EACH ROW begin
  460. declare v_table_name varchar(64) default 'trade$invoice_fmor';
  461. declare v_method_type varchar(6) default 'update';
  462. declare v_data_id int;
  463. declare v_data text default null;
  464. declare v_priority int default 1;
  465. set v_data_id=new.invoice_id;
  466. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  467. end
  468. ;;
  469. delimiter ;
  470. -- ----------------------------
  471. -- Triggers structure for table trade$invoice_fmor_dt
  472. -- ----------------------------
  473. DROP TRIGGER IF EXISTS `lucene_order_inv_dt_u`;
  474. delimiter ;;
  475. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_inv_dt_u` AFTER UPDATE ON `trade$invoice_fmor_dt` FOR EACH ROW begin
  476. declare v_table_name varchar(64) default 'trade$invoice_fmor';
  477. declare v_method_type varchar(6) default 'update';
  478. declare v_data_id int;
  479. declare v_data text default null;
  480. declare v_priority int default 1;
  481. set v_data_id=old.invoice_id;
  482. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  483. end
  484. ;;
  485. delimiter ;
  486. -- ----------------------------
  487. -- Triggers structure for table trade$invoice_fmor_dt
  488. -- ----------------------------
  489. DROP TRIGGER IF EXISTS `lucene_order_inv_dt_d`;
  490. delimiter ;;
  491. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_inv_dt_d` AFTER DELETE ON `trade$invoice_fmor_dt` FOR EACH ROW begin
  492. declare v_table_name varchar(64) default 'trade$invoice_fmor';
  493. declare v_method_type varchar(6) default 'update';
  494. declare v_data_id int;
  495. declare v_data text default null;
  496. declare v_priority int default 1;
  497. set v_data_id=old.invoice_id;
  498. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  499. end
  500. ;;
  501. delimiter ;
  502. -- ----------------------------
  503. -- Triggers structure for table trade$invoice_fmpu
  504. -- ----------------------------
  505. DROP TRIGGER IF EXISTS `lucene_purchase_inv_i`;
  506. delimiter ;;
  507. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_inv_i` AFTER INSERT ON `trade$invoice_fmpu` FOR EACH ROW begin
  508. declare v_table_name varchar(64) default 'trade$invoice_fmpu';
  509. declare v_method_type varchar(6) default 'insert';
  510. declare v_data_id int;
  511. declare v_data text default null;
  512. declare v_priority int default 1;
  513. set v_data_id=new.id;
  514. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  515. end
  516. ;;
  517. delimiter ;
  518. -- ----------------------------
  519. -- Triggers structure for table trade$invoice_fmpu
  520. -- ----------------------------
  521. DROP TRIGGER IF EXISTS `lucene_purchase_inv_u`;
  522. delimiter ;;
  523. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_inv_u` AFTER UPDATE ON `trade$invoice_fmpu` FOR EACH ROW begin
  524. declare v_table_name varchar(64) default 'trade$invoice_fmpu';
  525. declare v_method_type varchar(6) default 'update';
  526. declare v_data_id int;
  527. declare v_data text default null;
  528. declare v_priority int default 1;
  529. set v_data_id=old.id;
  530. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  531. end
  532. ;;
  533. delimiter ;
  534. -- ----------------------------
  535. -- Triggers structure for table trade$invoice_fmpu
  536. -- ----------------------------
  537. DROP TRIGGER IF EXISTS `lucene_purchase_inv_d`;
  538. delimiter ;;
  539. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_inv_d` AFTER DELETE ON `trade$invoice_fmpu` FOR EACH ROW begin
  540. declare v_table_name varchar(64) default 'trade$invoice_fmpu';
  541. declare v_method_type varchar(6) default 'delete';
  542. declare v_data_id int;
  543. declare v_data text default null;
  544. declare v_priority int default 1;
  545. set v_data_id=old.id;
  546. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  547. end
  548. ;;
  549. delimiter ;
  550. -- ----------------------------
  551. -- Triggers structure for table trade$invoice_fmpu_dt
  552. -- ----------------------------
  553. DROP TRIGGER IF EXISTS `lucene_purchase_inv_dt_i`;
  554. delimiter ;;
  555. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_inv_dt_i` AFTER INSERT ON `trade$invoice_fmpu_dt` FOR EACH ROW begin
  556. declare v_table_name varchar(64) default 'trade$invoice_fmpu';
  557. declare v_method_type varchar(6) default 'update';
  558. declare v_data_id int;
  559. declare v_data text default null;
  560. declare v_priority int default 1;
  561. set v_data_id=new.invoice_id;
  562. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  563. end
  564. ;;
  565. delimiter ;
  566. -- ----------------------------
  567. -- Triggers structure for table trade$invoice_fmpu_dt
  568. -- ----------------------------
  569. DROP TRIGGER IF EXISTS `lucene_purchase_inv_dt_u`;
  570. delimiter ;;
  571. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_inv_dt_u` AFTER UPDATE ON `trade$invoice_fmpu_dt` FOR EACH ROW begin
  572. declare v_table_name varchar(64) default 'trade$invoice_fmpu';
  573. declare v_method_type varchar(6) default 'update';
  574. declare v_data_id int;
  575. declare v_data text default null;
  576. declare v_priority int default 1;
  577. set v_data_id=old.invoice_id;
  578. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  579. end
  580. ;;
  581. delimiter ;
  582. -- ----------------------------
  583. -- Triggers structure for table trade$invoice_fmpu_dt
  584. -- ----------------------------
  585. DROP TRIGGER IF EXISTS `lucene_purchase_inv_dt_d`;
  586. delimiter ;;
  587. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_inv_dt_d` AFTER DELETE ON `trade$invoice_fmpu_dt` FOR EACH ROW begin
  588. declare v_table_name varchar(64) default 'trade$invoice_fmpu';
  589. declare v_method_type varchar(6) default 'update';
  590. declare v_data_id int;
  591. declare v_data text default null;
  592. declare v_priority int default 1;
  593. set v_data_id=old.invoice_id;
  594. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  595. end
  596. ;;
  597. delimiter ;
  598. -- ----------------------------
  599. -- Triggers structure for table trade$order
  600. -- ----------------------------
  601. DROP TRIGGER IF EXISTS `lucene_order_i`;
  602. delimiter ;;
  603. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_i` AFTER INSERT ON `trade$order` FOR EACH ROW begin
  604. declare v_table_name varchar(64) default 'trade$order';
  605. declare v_method_type varchar(6) default 'insert';
  606. declare v_data_id int;
  607. declare v_data text default null;
  608. declare v_priority int default 1;
  609. set v_data_id=new.id;
  610. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  611. end
  612. ;;
  613. delimiter ;
  614. -- ----------------------------
  615. -- Triggers structure for table trade$order
  616. -- ----------------------------
  617. DROP TRIGGER IF EXISTS `lucene_order_u`;
  618. delimiter ;;
  619. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_u` AFTER UPDATE ON `trade$order` FOR EACH ROW begin
  620. declare v_table_name varchar(64) default 'trade$order';
  621. declare v_method_type varchar(6) default 'update';
  622. declare v_data_id int;
  623. declare v_data text default null;
  624. declare v_priority int default 1;
  625. set v_data_id=old.id;
  626. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  627. end
  628. ;;
  629. delimiter ;
  630. -- ----------------------------
  631. -- Triggers structure for table trade$order
  632. -- ----------------------------
  633. DROP TRIGGER IF EXISTS `lucene_order_d`;
  634. delimiter ;;
  635. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_d` AFTER DELETE ON `trade$order` FOR EACH ROW begin
  636. declare v_table_name varchar(64) default 'trade$order';
  637. declare v_method_type varchar(6) default 'delete';
  638. declare v_data_id int;
  639. declare v_data text default null;
  640. declare v_priority int default 1;
  641. set v_data_id=old.id;
  642. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  643. end
  644. ;;
  645. delimiter ;
  646. -- ----------------------------
  647. -- Triggers structure for table trade$order_detail
  648. -- ----------------------------
  649. DROP TRIGGER IF EXISTS `lucene_order_dt_i`;
  650. delimiter ;;
  651. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_dt_i` AFTER INSERT ON `trade$order_detail` FOR EACH ROW begin
  652. declare v_table_name varchar(64) default 'trade$order';
  653. declare v_method_type varchar(6) default 'update';
  654. declare v_data_id int;
  655. declare v_data text default null;
  656. declare v_priority int default 1;
  657. set v_data_id=new.order_id;
  658. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  659. end
  660. ;;
  661. delimiter ;
  662. -- ----------------------------
  663. -- Triggers structure for table trade$order_detail
  664. -- ----------------------------
  665. DROP TRIGGER IF EXISTS `lucene_order_dt_u`;
  666. delimiter ;;
  667. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_dt_u` AFTER UPDATE ON `trade$order_detail` FOR EACH ROW begin
  668. declare v_table_name varchar(64) default 'trade$order';
  669. declare v_method_type varchar(6) default 'update';
  670. declare v_data_id int;
  671. declare v_data text default null;
  672. declare v_priority int default 1;
  673. set v_data_id=old.order_id;
  674. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  675. end
  676. ;;
  677. delimiter ;
  678. -- ----------------------------
  679. -- Triggers structure for table trade$order_detail
  680. -- ----------------------------
  681. DROP TRIGGER IF EXISTS `lucene_order_dt_d`;
  682. delimiter ;;
  683. CREATE DEFINER = `root`@`%` TRIGGER `lucene_order_dt_d` AFTER DELETE ON `trade$order_detail` FOR EACH ROW begin
  684. declare v_table_name varchar(64) default 'trade$order';
  685. declare v_method_type varchar(6) default 'update';
  686. declare v_data_id int;
  687. declare v_data text default null;
  688. declare v_priority int default 1;
  689. set v_data_id=old.order_id;
  690. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  691. end
  692. ;;
  693. delimiter ;
  694. -- ----------------------------
  695. -- Triggers structure for table trade$purchase
  696. -- ----------------------------
  697. DROP TRIGGER IF EXISTS `lucene_purchase_i`;
  698. delimiter ;;
  699. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_i` AFTER INSERT ON `trade$purchase` FOR EACH ROW begin
  700. declare v_table_name varchar(64) default 'trade$purchase';
  701. declare v_method_type varchar(6) default 'insert';
  702. declare v_data_id int;
  703. declare v_data text default null;
  704. declare v_priority int default 1;
  705. set v_data_id=new.id;
  706. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  707. end
  708. ;;
  709. delimiter ;
  710. -- ----------------------------
  711. -- Triggers structure for table trade$purchase
  712. -- ----------------------------
  713. DROP TRIGGER IF EXISTS `lucene_purchase_u`;
  714. delimiter ;;
  715. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_u` AFTER UPDATE ON `trade$purchase` FOR EACH ROW begin
  716. declare v_table_name varchar(64) default 'trade$purchase';
  717. declare v_method_type varchar(6) default 'update';
  718. declare v_data_id int;
  719. declare v_data text default null;
  720. declare v_priority int default 1;
  721. set v_data_id=old.id;
  722. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  723. end
  724. ;;
  725. delimiter ;
  726. -- ----------------------------
  727. -- Triggers structure for table trade$purchase
  728. -- ----------------------------
  729. DROP TRIGGER IF EXISTS `lucene_purchase_d`;
  730. delimiter ;;
  731. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_d` AFTER DELETE ON `trade$purchase` FOR EACH ROW begin
  732. declare v_table_name varchar(64) default 'trade$purchase';
  733. declare v_method_type varchar(6) default 'delete';
  734. declare v_data_id int;
  735. declare v_data text default null;
  736. declare v_priority int default 1;
  737. set v_data_id=old.id;
  738. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  739. end
  740. ;;
  741. delimiter ;
  742. -- ----------------------------
  743. -- Triggers structure for table trade$purchase_detail
  744. -- ----------------------------
  745. DROP TRIGGER IF EXISTS `lucene_purchase_dt_i`;
  746. delimiter ;;
  747. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_dt_i` AFTER INSERT ON `trade$purchase_detail` FOR EACH ROW begin
  748. declare v_table_name varchar(64) default 'trade$purchase';
  749. declare v_method_type varchar(6) default 'update';
  750. declare v_data_id int;
  751. declare v_data text default null;
  752. declare v_priority int default 1;
  753. set v_data_id=new.purchase_id;
  754. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  755. end
  756. ;;
  757. delimiter ;
  758. -- ----------------------------
  759. -- Triggers structure for table trade$purchase_detail
  760. -- ----------------------------
  761. DROP TRIGGER IF EXISTS `lucene_purchase_dt_u`;
  762. delimiter ;;
  763. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_dt_u` AFTER UPDATE ON `trade$purchase_detail` FOR EACH ROW begin
  764. declare v_table_name varchar(64) default 'trade$purchase';
  765. declare v_method_type varchar(6) default 'update';
  766. declare v_data_id int;
  767. declare v_data text default null;
  768. declare v_priority int default 1;
  769. set v_data_id=old.purchase_id;
  770. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  771. end
  772. ;;
  773. delimiter ;
  774. -- ----------------------------
  775. -- Triggers structure for table trade$purchase_detail
  776. -- ----------------------------
  777. DROP TRIGGER IF EXISTS `lucene_purchase_dt_d`;
  778. delimiter ;;
  779. CREATE DEFINER = `root`@`%` TRIGGER `lucene_purchase_dt_d` AFTER DELETE ON `trade$purchase_detail` FOR EACH ROW begin
  780. declare v_table_name varchar(64) default 'trade$purchase';
  781. declare v_method_type varchar(6) default 'update';
  782. declare v_data_id int;
  783. declare v_data text default null;
  784. declare v_priority int default 1;
  785. set v_data_id=old.purchase_id;
  786. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  787. end
  788. ;;
  789. delimiter ;
  790. -- 2018年5月22日 20:01:19 dongbw
  791. -- ----------------------------
  792. -- Triggers structure for table v$product$private
  793. -- ----------------------------
  794. DROP TRIGGER IF EXISTS `lucene_product_i`;
  795. delimiter ;;
  796. CREATE DEFINER = `root`@`%` TRIGGER `lucene_product_i` AFTER INSERT ON `products` FOR EACH ROW begin
  797. declare v_table_name varchar(64) default 'v$product$private';
  798. declare v_method_type varchar(6) default 'insert';
  799. declare v_data_id int;
  800. declare v_data text default null;
  801. declare v_priority int default 1;
  802. set v_data_id=new.pr_id;
  803. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  804. end
  805. ;;
  806. delimiter ;
  807. -- ----------------------------
  808. -- Triggers structure for table v$product$private
  809. -- ----------------------------
  810. DROP TRIGGER IF EXISTS `lucene_product_u`;
  811. delimiter ;;
  812. CREATE DEFINER = `root`@`%` TRIGGER `lucene_product_u` AFTER UPDATE ON `products` FOR EACH ROW begin
  813. declare v_table_name varchar(64) default 'v$product$private';
  814. declare v_method_type varchar(6) default 'update';
  815. declare v_data_id int;
  816. declare v_data text default null;
  817. declare v_priority int default 1;
  818. set v_data_id=old.pr_id;
  819. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  820. end
  821. ;;
  822. delimiter ;
  823. -- ----------------------------
  824. -- Triggers structure for table v$product$private
  825. -- ----------------------------
  826. DROP TRIGGER IF EXISTS `lucene_product_d`;
  827. delimiter ;;
  828. CREATE DEFINER = `root`@`%` TRIGGER `lucene_product_d` AFTER DELETE ON `products` FOR EACH ROW begin
  829. declare v_table_name varchar(64) default 'v$product$private';
  830. declare v_method_type varchar(6) default 'delete';
  831. declare v_data_id int;
  832. declare v_data text default null;
  833. declare v_priority int default 1;
  834. set v_data_id=old.pr_id;
  835. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  836. end
  837. ;;
  838. delimiter ;
  839. -- 物料私有属性新增、更新、删除时也需要更新物料索引 dongbw 2018年5月28日 16:13:46
  840. -- ----------------------------
  841. -- Triggers structure for table product$private
  842. -- ----------------------------
  843. DROP TRIGGER IF EXISTS `lucene_product_private_i`;
  844. delimiter ;;
  845. CREATE DEFINER = `root`@`%` TRIGGER `lucene_product_private_i` AFTER INSERT ON `product$private` FOR EACH ROW begin
  846. declare v_table_name varchar(64) default 'v$product$private';
  847. declare v_method_type varchar(6) default 'update';
  848. declare v_data_id int;
  849. declare v_data text default null;
  850. declare v_priority int default 1;
  851. set v_data_id=new.pr_id;
  852. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  853. end
  854. ;;
  855. delimiter ;
  856. -- ----------------------------
  857. -- Triggers structure for table product$private
  858. -- ----------------------------
  859. DROP TRIGGER IF EXISTS `lucene_product_private_u`;
  860. delimiter ;;
  861. CREATE DEFINER = `root`@`%` TRIGGER `lucene_product_private_u` AFTER UPDATE ON `product$private` FOR EACH ROW begin
  862. declare v_table_name varchar(64) default 'v$product$private';
  863. declare v_method_type varchar(6) default 'update';
  864. declare v_data_id int;
  865. declare v_data text default null;
  866. declare v_priority int default 1;
  867. set v_data_id=old.pr_id;
  868. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  869. end
  870. ;;
  871. delimiter ;
  872. -- ----------------------------
  873. -- Triggers structure for table product$private
  874. -- ----------------------------
  875. DROP TRIGGER IF EXISTS `lucene_product_private_d`;
  876. delimiter ;;
  877. CREATE DEFINER = `root`@`%` TRIGGER `lucene_product_private_d` AFTER DELETE ON `product$private` FOR EACH ROW begin
  878. declare v_table_name varchar(64) default 'v$product$private';
  879. declare v_method_type varchar(6) default 'update';
  880. declare v_data_id int;
  881. declare v_data text default null;
  882. declare v_priority int default 1;
  883. set v_data_id=old.pr_id;
  884. call enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  885. end
  886. ;;
  887. delimiter ;