00_Preprocessing.sql 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. -- 删除不好,不能在原库运行,改用创建中间表的方式,减小迁移数据量,加速迁移
  2. -- 需求场景:按站点迁移一个节点,须保留的站点id人工整理
  3. -- 创建所需的中间表
  4. drop table if exists exchange_appendix;
  5. create table exchange_appendix like wcmappendix;
  6. drop table if exists exchange_channel;
  7. create table exchange_channel like wcmchannel;
  8. drop table if exists exchange_channelchildindexquote;
  9. create table exchange_channelchildindexquote like wcmchannelchildindexquote;
  10. drop table if exists exchange_channelsyn;
  11. create table exchange_channelsyn like wcmchannelsyn;
  12. drop table if exists exchange_chnldoc;
  13. create table exchange_chnldoc like wcmchnldoc;
  14. drop table if exists exchange_document;
  15. create table exchange_document like wcmdocument;
  16. drop table if exists exchange_folderpublishconfig;
  17. create table exchange_folderpublishconfig like wcmfolderpublishconfig;
  18. drop table if exists exchange_template;
  19. create table exchange_template like wcmtemplate;
  20. drop table if exists exchange_templateargument;
  21. create table exchange_templateargument like wcmtemplateargument;
  22. drop table if exists exchange_templateemploy;
  23. create table exchange_templateemploy like wcmtemplateemploy;
  24. drop table if exists exchange_templatenest;
  25. create table exchange_templatenest like wcmtemplatenest;
  26. drop table if exists exchange_templatequote;
  27. create table exchange_templatequote like wcmtemplatequote;
  28. drop table if exists exchange_website;
  29. create table exchange_website like wcmwebsite;
  30. drop table if exists exchange_classinfo;
  31. create table exchange_classinfo like xwcmclassinfo;
  32. drop table if exists exchange_classinfoview;
  33. create table exchange_classinfoview like xwcmclassinfoview;
  34. drop table if exists exchange_dbfieldinfo;
  35. create table exchange_dbfieldinfo like xwcmdbfieldinfo;
  36. drop table if exists exchange_material;
  37. create table exchange_material like xwcmmaterial;
  38. drop table if exists exchange_materialquote;
  39. create table exchange_materialquote like xwcmmaterialquote;
  40. drop table if exists exchange_metaviewemployer;
  41. create table exchange_metaviewemployer like xwcmmetaviewemployer;
  42. drop table if exists exchange_metaviewfieldgroup;
  43. create table exchange_metaviewfieldgroup like xwcmmetaviewfieldgroup;
  44. drop table if exists exchange_tableinfo;
  45. create table exchange_tableinfo like xwcmtableinfo;
  46. drop table if exists exchange_viewfieldinfo;
  47. create table exchange_viewfieldinfo like xwcmviewfieldinfo;
  48. drop table if exists exchange_viewinfo;
  49. create table exchange_viewinfo like xwcmviewinfo;
  50. INSERT INTO exchange_website SELECT * from wcmwebsite where siteid in (
  51. 19,53,60,78,84,86,92,93,96,97,98,99,102,103,105,109,112,114,115,119,125,131,132,162,130,168,171,172,173,174,175,178
  52. );
  53. -- 修复部分站点站点不显示问题
  54. UPDATE exchange_website set MEDIATYPE = 1;
  55. -- 删除多余栏目
  56. INSERT INTO exchange_channel SELECT * from wcmchannel where siteId in (SELECT siteId from exchange_website) and status >= 0;
  57. -- 栏目模板触发发布关联关系
  58. INSERT INTO exchange_channelchildindexquote SELECT * from wcmchannelchildindexquote where (FOLDERID IN (SELECT siteId from exchange_website) and FOLDERTYPE = 103) OR (FOLDERID IN (SELECT channelId from exchange_channel) and FOLDERTYPE = 101);
  59. -- 文档分发关系
  60. INSERT INTO exchange_channelsyn SELECT * from wcmchannelsyn where srcchannel in (SELECT channelId from exchange_channel) and tochannel in (SELECT channelId from exchange_channel);
  61. -- 存放路径
  62. INSERT INTO exchange_folderpublishconfig SELECT * from wcmfolderpublishconfig where (FOLDERID IN (SELECT siteId from exchange_website) and FOLDERTYPE = 103) OR (FOLDERID IN (SELECT channelId from exchange_channel) and FOLDERTYPE = 101);
  63. -- 多余模板
  64. INSERT INTO exchange_template SELECT * from wcmtemplate where rootid = 0 or rootid in (SELECT siteId from exchange_website);
  65. -- 模板变量
  66. INSERT INTO exchange_templateargument SELECT * from wcmtemplateargument where TEMPLATEID in (SELECT TEMPID from exchange_template);
  67. -- 模板栏目绑定关系
  68. INSERT INTO exchange_templateemploy SELECT * from wcmtemplateemploy WHERE (TEMPLATEID in (SELECT TEMPID from exchange_template)) or (EMPLOYERID IN (SELECT siteId from exchange_website) and EMPLOYERTYPE = 103) OR (EMPLOYERID IN (SELECT channelId from exchange_channel) and EMPLOYERTYPE = 101);
  69. -- 嵌套模板信息
  70. INSERT INTO exchange_templatenest SELECT * from wcmtemplatenest WHERE (templateId in (SELECT TEMPID from exchange_template)) and (nestedtemplateId in (SELECT TEMPID from exchange_template));
  71. -- 模板引用信息
  72. INSERT INTO exchange_templatequote SELECT * from wcmtemplatequote WHERE (templateId in (SELECT TEMPID from exchange_template)) or (quotedFolderId in (SELECT CHANNELID from exchange_channel) and quotedFolderType = 101) or (quotedFolderId in (SELECT siteId from exchange_website) and quotedFolderType = 103);
  73. -- 栏目绑定的视图
  74. INSERT INTO exchange_metaviewemployer SELECT * from xwcmmetaviewemployer where CHANNELID in (SELECT CHANNELID from exchange_channel);
  75. -- 视图信息
  76. INSERT INTO exchange_viewinfo SELECT * from xwcmviewinfo where VIEWINFOID in (SELECT VIEWID from exchange_metaviewemployer);
  77. -- 视图字段信息
  78. INSERT INTO exchange_viewfieldinfo SELECT * from xwcmviewfieldinfo where VIEWID in (SELECT viewinfoid from exchange_viewinfo);
  79. INSERT INTO exchange_metaviewfieldgroup SELECT * from xwcmmetaviewfieldgroup where metaviewid in (SELECT viewinfoid from exchange_viewinfo);
  80. -- 元数据表信息
  81. INSERT INTO exchange_tableinfo SELECT * from xwcmtableinfo where TABLEINFOID in (SELECT MAINTABLEID from exchange_viewinfo);
  82. INSERT INTO exchange_dbfieldinfo SELECT * from xwcmdbfieldinfo where TABLEID in (SELECT TABLEINFOID from exchange_tableinfo);
  83. -- --------数据记录
  84. INSERT INTO exchange_chnldoc SELECT * from wcmchnldoc WHERE CHNLID in (SELECT CHANNELID from exchange_channel);
  85. -- exchange_chnldoc
  86. INSERT INTO exchange_document SELECT * from wcmdocument WHERE docchannel in (SELECT CHANNELID from exchange_channel);
  87. -- xwcmmaterialquote记录
  88. INSERT INTO exchange_materialquote SELECT * from xwcmmaterialquote WHERE DOCID in (SELECT DOCID from wcmdocument);
  89. -- xwcmmaterial记录
  90. INSERT INTO exchange_material SELECT * from xwcmmaterial WHERE materialId in (SELECT materialId from exchange_materialquote);
  91. -- SELECT CONCAT('DROP TABLE IF EXISTS exchange_metatable',TABLENAME,';') from exchange_tableinfo;
  92. -- SELECT CONCAT('create table exchange_metatable',TABLENAME,' like wcmmetatable',TABLENAME ,';') from exchange_tableinfo;
  93. -- SELECT CONCAT('INSERT INTO exchange_metatable',TABLENAME,' select * from wcmmetatable',TABLENAME ,' where metadataId in (select docid from exchange_document);') from exchange_tableinfo;