浏览代码

优化迁移sql

xxy 6 年之前
父节点
当前提交
5f19df8d8c
共有 19 个文件被更改,包括 671 次插入37 次删除
  1. 38 17
      TRS.WCM.Developer/test/com/trs/web2frame/SqlAutoCreateTest.java
  2. 1 1
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/0_update_data_dbfield.sql
  3. 2 2
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/1_data_migration_offset.sql
  4. 1 1
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/3_sp_data_migration_mas_masid.sql
  5. 1 1
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/3_sp_data_migration_wcmwebsite.sql
  6. 3 3
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/如增量迁移需运行SQL/3_sp_data_migration_wcmchnldoc.sql
  7. 3 2
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/如增量迁移需运行SQL/3_sp_data_migration_wcmdocument.sql
  8. 2 2
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/如增量迁移需运行SQL/3_sp_data_migration_wcmmetablexx.sql
  9. 8 8
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/如增量迁移需运行SQL/3_sp_data_migration_wcmmetatable.sql
  10. 98 0
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city1/00_Preprocessing.sql
  11. 101 0
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city2/00_Preprocessing.sql
  12. 11 0
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city2/00_alter_metadata.sql
  13. 99 0
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city3/00_Preprocessing.sql
  14. 1 0
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city5/00_Preprocessing.sql
  15. 120 0
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city6/00_Preprocessing.sql
  16. 6 0
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city6/00_alter_metadata.sql
  17. 34 0
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city6/00_rename_table.sql
  18. 108 0
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city7/00_Preprocessing.sql
  19. 34 0
      TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city7/00_rename_table.sql

+ 38 - 17
TRS.WCM.Developer/test/com/trs/web2frame/SqlAutoCreateTest.java

@@ -29,15 +29,14 @@ public class SqlAutoCreateTest extends TestCase {
         //来源表名称
         String srcTabelName = "wcmdocument";
         //需要合并到空视图的栏目IDS
-        String channelIds = "1,2";
-        //来源表数据过滤条件
-        String where = " DOCCHANNEL in (" + channelIds + ") ";
-        //TODO
-
-
+        //String channelIds = "1,2";
+        //TODO 来源表数据过滤条件
+        //String where = " DOCCHANNEL in (" + channelIds + ") ";
+        String where = "dockind = 0";
         //生成批量插入sql
         String insertSql = buildInsertSql(srcTabelName, toTabelName, where);
         System.out.println("-- insert SQL");
+        System.out.println("SET @max_mum = IFNULL((select MAX("+toTabelName+"Id ) from "+toTabelName+"),0);");
         System.out.println(insertSql);
         //生成chnldoc SQL
         String updateChnldocSql = buildUpdateChnldocSql(toViewId, channelIds);
@@ -63,15 +62,15 @@ public class SqlAutoCreateTest extends TestCase {
         String[] channelIdArr = CMyString.split(channelIds, ",");
         for (String channelIdStr : channelIdArr){
             StringBuilder updateViewEmployerSql = new StringBuilder();
-            updateViewEmployerSql.append("insert into xwcmmetaviewemployer\n" +
-                    "              (\n" +
-                    "                VIEWID,\n" +
-                    "                CHANNELID,\n" +
-                    "                METAVIEWEMPLOYERID,\n" +
-                    "                EmployerType,\n" +
-                    "                EmployerId\n" +
-                    "              )\n" +
-                    "              SELECT ")
+            updateViewEmployerSql.append("insert into xwcmmetaviewemployer" +
+                    " (" +
+                    " VIEWID," +
+                    " CHANNELID," +
+                    " METAVIEWEMPLOYERID," +
+                    " EmployerType," +
+                    " EmployerId" +
+                    " )" +
+                    " SELECT ")
                     .append(toViewId).append(",")
                     .append(channelIdStr).append(",")
                     .append(" ifnull(max(METAVIEWEMPLOYERID), 0) + 1").append(",")
@@ -91,7 +90,7 @@ public class SqlAutoCreateTest extends TestCase {
         return deleteViewEmployerSql.toString();
     }
 
-    private String buildUpdateDocumentSql(int toViewId, String channelIds) {
+    private String buildUpdateDocumentSql(int toViewId, String where) {
 
         StringBuilder updateDocumentSql = new StringBuilder();
         updateDocumentSql.append("UPDATE wcmdocument SET DOCKIND = ")
@@ -102,9 +101,28 @@ public class SqlAutoCreateTest extends TestCase {
 
         return updateDocumentSql.toString();
     }
+    /*
+    private String buildUpdateDocumentSql(int toViewId, String channelIds) {
 
-    private String buildUpdateChnldocSql(int toViewId, String channelIds) {
+        StringBuilder updateDocumentSql = new StringBuilder();
+        updateDocumentSql.append("UPDATE wcmdocument SET DOCKIND = ")
+                .append(toViewId)
+                .append(" WHERE DOCCHANNEL in (")
+                .append(channelIds)
+                .append(") ;");
 
+        return updateDocumentSql.toString();
+    }
+    */
+    private String buildUpdateChnldocSql(int toViewId, String where) {
+        StringBuilder updateChnldocSql = new StringBuilder();
+        updateChnldocSql.append("UPDATE wcmchnldoc SET DOCKIND = ")
+                .append(toViewId)
+                .append(" " + where + ";");
+        return updateChnldocSql.toString();
+    }
+    /*
+    private String buildUpdateChnldocSql(int toViewId, String channelIds) {
         StringBuilder updateChnldocSql = new StringBuilder();
         updateChnldocSql.append("UPDATE wcmchnldoc SET DOCKIND = ")
                 .append(toViewId)
@@ -114,6 +132,7 @@ public class SqlAutoCreateTest extends TestCase {
 
         return updateChnldocSql.toString();
     }
+    */
 
     private String buildInsertSql(String srcTabelName, String toTabelName, String where) throws CMyException {
 
@@ -133,8 +152,10 @@ public class SqlAutoCreateTest extends TestCase {
         StringBuilder insertSql = new StringBuilder(" INSERT INTO ");
         insertSql.append(toTabelName)
                 .append(" (")
+                .append(toTabelName+"Id,")
                 .append(keyBuilder)
                 .append(") SELECT ")
+                .append(" (@max_num := @max_num + 1),")
                 .append(valueBuilder)
                 .append(" FROM ")
                 .append(srcTabelName);

+ 1 - 1
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/0_update_data_dbfield.sql

@@ -56,7 +56,7 @@ CREATE PROCEDURE update_data_dbfield (
                         add column AttachPic smallint(6) DEFAULT NULL,
                         add column AttachVideo smallint(6) DEFAULT NULL,
                         add column AttachAudio smallint(6) DEFAULT NULL,
-                        add column ThumbFiles varchar(2000) DEFAULT NULL,
+                        add column ThumbFiles varchar(1000) DEFAULT NULL,
                         add column VersionNum int(11) DEFAULT NULL,
                         add column DocType int(11) DEFAULT NULL;
   ');

+ 2 - 2
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/1_data_migration_offset.sql

@@ -18,13 +18,13 @@ CREATE  TABLE `meta_data`(
 
 CREATE  TABLE `relphoto_doc`(
   `docid` BIGINT(20) NOT NULL comment '文档ID',
-  `appendixids` VARCHAR(400) NOT NULL comment '附件字段',
+  `appendixids` VARCHAR(3000) NOT NULL comment '附件字段',
   PRIMARY KEY (`docid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE  TABLE `relvideo_doc`(
   `docid` BIGINT(20) NOT NULL comment '文档ID',
-  `appendixids` VARCHAR(400) NOT NULL comment '附件字段',
+  `appendixids` VARCHAR(3000) NOT NULL comment '附件字段',
   PRIMARY KEY (`docid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 

+ 1 - 1
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/3_sp_data_migration_mas_masid.sql

@@ -15,7 +15,7 @@ CREATE PROCEDURE sp_data_migration_masid(IN prevMasId BIGINT(20),
     DECLARE  f_CREATEDUSER varchar(255) DEFAULT NULL;
     DECLARE  f_CREATEDUSERID int(11) DEFAULT NULL;
     DECLARE  f_CREATEDUSERNICKNAME varchar(255) DEFAULT NULL;
-    DECLARE  f_LASTMODIFIEDTIME datetime DEFAULT NULL;
+    DECLARE  f_LASTMODIFIEDTIME bigint DEFAULT NULL;
     DECLARE  f_LASTMODIFIEDUSER varchar(255) DEFAULT NULL;
     DECLARE  f_LASTMODIFIEDUSERID int(11) DEFAULT NULL;
     DECLARE  f_srcObjType varchar(255) DEFAULT NULL;

+ 1 - 1
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/3_sp_data_migration_wcmwebsite.sql

@@ -171,7 +171,7 @@ CREATE PROCEDURE sp_data_migration_wcmwebsite(IN citySuffix VARCHAR(255), IN pre
                                                      'CTYPE',
                                                  ') ',
                                                  'values(',
-                                                    (v_classificationId), ',',
+                                                    (v_classificationId+1), ',',
                                                     '\'', '贵州迁移站点_', citySuffix, '\',',
                                                     '\'', right(citySuffix, 5), '\',',
                                                     '11',

+ 3 - 3
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/如增量迁移需运行SQL/3_sp_data_migration_wcmchnldoc.sql

@@ -1,8 +1,8 @@
 
 
-DROP PROCEDURE IF EXISTS sp_data_migration_wcmchnldoc;
+DROP PROCEDURE IF EXISTS sp_data_migration_increment_wcmchnldoc;
 DELIMITER $$
-CREATE PROCEDURE sp_data_migration_wcmchnldoc(IN prevRecId BIGINT(20),
+CREATE PROCEDURE sp_data_migration_increment_wcmchnldoc(IN prevRecId BIGINT(20),
                                                   IN recIdOffset BIGINT(20),
                                                   IN docIdOffset BIGINT(20),
                                                   IN siteIdOffset BIGINT(20),
@@ -104,7 +104,7 @@ CREATE PROCEDURE sp_data_migration_wcmchnldoc(IN prevRecId BIGINT(20),
       null
     -- 迭代十五才有的字段 ACTIONUSER
     FROM wcmchnldoc
-    where CHNLID > 0 and SITEID > 0
+    where CHNLID > 0 and SITEID > 0 AND RECID > prevRecId
     ORDER BY RECID ASC ;
 
 	DECLARE CONTINUE HANDLER FOR NOT FOUND SET isover = 1;

+ 3 - 2
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/如增量迁移需运行SQL/3_sp_data_migration_wcmdocument.sql

@@ -1,8 +1,8 @@
 
 
-DROP PROCEDURE IF EXISTS sp_data_migration_wcmdocument;
+DROP PROCEDURE IF EXISTS sp_data_migration_increment_wcmdocument;
 DELIMITER $$
-CREATE PROCEDURE sp_data_migration_wcmdocument(IN prevDocId BIGINT(20),
+CREATE PROCEDURE sp_data_migration_increment_wcmdocument(IN prevDocId BIGINT(20),
                                               IN docIdOffset BIGINT(20),
                                               IN viewIdOffset BIGINT(20),
                                               IN siteIdOffset BIGINT(20),
@@ -183,6 +183,7 @@ CREATE PROCEDURE sp_data_migration_wcmdocument(IN prevDocId BIGINT(20),
       0,
       0
 		FROM wcmdocument
+		WHERE docid > prevDocId
 		ORDER BY docid asc;
 
 	DECLARE CONTINUE HANDLER FOR NOT FOUND SET isover = 1;

+ 2 - 2
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/如增量迁移需运行SQL/3_sp_data_migration_wcmmetablexx.sql

@@ -1,8 +1,8 @@
 
 
-DROP PROCEDURE IF EXISTS sp_data_migration_wcmmetablexx;
+DROP PROCEDURE IF EXISTS sp_data_migration_increment_wcmmetablexx;
 DELIMITER $$
-CREATE PROCEDURE sp_data_migration_wcmmetablexx(IN metableName VARCHAR(255),
+CREATE PROCEDURE sp_data_migration_increment_wcmmetablexx(IN metableName VARCHAR(255),
                                               IN prevDocId BIGINT(20),
                                               IN docIdOffset BIGINT(20),
                                               IN channelIdOffset BIGINT(20))

+ 8 - 8
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/如增量迁移需运行SQL/3_sp_data_migration_wcmmetatable.sql

@@ -1,8 +1,8 @@
 
 
-DROP PROCEDURE IF EXISTS sp_data_migration_wcmmetatable;
+DROP PROCEDURE IF EXISTS sp_data_migration_increment_wcmmetatable;
 DELIMITER $$
-CREATE PROCEDURE sp_data_migration_wcmmetatable(IN citySuffix VARCHAR(20),
+CREATE PROCEDURE sp_data_migration_increment_wcmmetatable(IN citySuffix VARCHAR(20),
                                               IN prevTableInfoId VARCHAR(100),
                                               IN prevDocId BIGINT(20),
                                               IN docIdOffset BIGINT(20),
@@ -58,7 +58,7 @@ CREATE PROCEDURE sp_data_migration_wcmmetatable(IN citySuffix VARCHAR(20),
             EXECUTE stmt;
             deallocate prepare stmt;
 
-            call sp_data_migration_wcmmetablexx(concat('wcmmetatable', f_TABLENAME, citySuffix), prevDocId, docIdOffset, channelIdOffset);
+            call sp_data_migration_increment_wcmmetablexx(concat('wcmmetatable', f_TABLENAME, citySuffix), prevDocId, docIdOffset, channelIdOffset);
 
             if prevTableInfoId = 0
               then
@@ -68,9 +68,8 @@ CREATE PROCEDURE sp_data_migration_wcmmetatable(IN citySuffix VARCHAR(20),
                 EXECUTE stmt;
                 deallocate prepare stmt;
 
-                set @id_sql = concat('INSERT INTO trs_hycloud_iip.wcmid VALUES (','\'','wcmmetatable',
-                                 f_TABLENAME, citySuffix, '\'',', ', @meta_data_id + 1,', 1, ','\'','wcmmetatable',f_TABLENAME, citySuffix,'ID','\'',');');
-                select concat('插入wcmid元数据sql: ', @id_sql ) info;
+                set @id_sql = concat('UPDATE trs_hycloud_iip.wcmid SET NEXTID = ', @meta_data_id + 1,' where TABLENAME = ','\'','wcmmetatable',
+                                     f_TABLENAME, citySuffix, '\'');
                 prepare stmt from @id_sql;
                 EXECUTE stmt;
                 deallocate prepare stmt;
@@ -81,8 +80,9 @@ CREATE PROCEDURE sp_data_migration_wcmmetatable(IN citySuffix VARCHAR(20),
               EXECUTE stmt;
               deallocate prepare stmt;
 
-              set @id_sql = concat('UPDATE trs_hycloud_iip.wcmid SET NEXTID = ', @meta_data_id + 1,' where TABLENAME = ','\'','wcmmetatable',
-                                   f_TABLENAME, citySuffix, '\'');
+              set @id_sql = concat('INSERT INTO trs_hycloud_iip.wcmid VALUES (','\'','wcmmetatable',
+                               f_TABLENAME, citySuffix, '\'',', ', @meta_data_id + 1,', 1, ','\'','wcmmetatable',f_TABLENAME, citySuffix,'ID','\'',');');
+              select concat('插入wcmid元数据sql: ', @id_sql ) info;
               prepare stmt from @id_sql;
               EXECUTE stmt;
               deallocate prepare stmt;

+ 98 - 0
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city1/00_Preprocessing.sql

@@ -0,0 +1,98 @@
+-- 删除不好,不能在原库运行,改用创建中间表的方式,减小迁移数据量,加速迁移
+-- 需求场景:按站点迁移一个节点,须保留的站点id人工整理
+
+-- 创建所需的中间表
+drop table if exists exchange_appendix;
+create table exchange_appendix like wcmappendix;
+drop table if exists exchange_channel;
+create table exchange_channel like wcmchannel;
+drop table if exists exchange_channelchildindexquote;
+create table exchange_channelchildindexquote like wcmchannelchildindexquote;
+drop table if exists exchange_channelsyn;
+create table exchange_channelsyn like wcmchannelsyn;
+drop table if exists exchange_chnldoc;
+create table exchange_chnldoc like wcmchnldoc;
+drop table if exists exchange_document;
+create table exchange_document like wcmdocument;
+drop table if exists exchange_folderpublishconfig;
+create table exchange_folderpublishconfig like wcmfolderpublishconfig;
+drop table if exists exchange_template;
+create table exchange_template like wcmtemplate;
+drop table if exists exchange_templateargument;
+create table exchange_templateargument like wcmtemplateargument;
+drop table if exists exchange_templateemploy;
+create table exchange_templateemploy like wcmtemplateemploy;
+drop table if exists exchange_templatenest;
+create table exchange_templatenest like wcmtemplatenest;
+drop table if exists exchange_templatequote;
+create table exchange_templatequote like wcmtemplatequote;
+drop table if exists exchange_website;
+create table exchange_website like wcmwebsite;
+drop table if exists exchange_classinfo;
+create table exchange_classinfo like xwcmclassinfo;
+drop table if exists exchange_classinfoview;
+create table exchange_classinfoview like xwcmclassinfoview;
+drop table if exists exchange_dbfieldinfo;
+create table exchange_dbfieldinfo like xwcmdbfieldinfo;
+drop table if exists exchange_material;
+create table exchange_material like xwcmmaterial;
+drop table if exists exchange_materialquote;
+create table exchange_materialquote like xwcmmaterialquote;
+drop table if exists exchange_metaviewemployer;
+create table exchange_metaviewemployer like xwcmmetaviewemployer;
+drop table if exists exchange_metaviewfieldgroup;
+create table exchange_metaviewfieldgroup like xwcmmetaviewfieldgroup;
+drop table if exists exchange_tableinfo;
+create table exchange_tableinfo like xwcmtableinfo;
+drop table if exists exchange_viewfieldinfo;
+create table exchange_viewfieldinfo like xwcmviewfieldinfo;
+drop table if exists exchange_viewinfo;
+create table exchange_viewinfo like xwcmviewinfo;
+
+INSERT INTO exchange_website SELECT  * from wcmwebsite where siteid in (
+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
+);
+-- 修复部分站点站点不显示问题
+UPDATE exchange_website set MEDIATYPE = 1;
+-- 删除多余栏目
+INSERT INTO exchange_channel SELECT * from wcmchannel where siteId in (SELECT siteId from exchange_website) and status >= 0;
+-- 栏目模板触发发布关联关系
+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);
+-- 文档分发关系
+INSERT INTO exchange_channelsyn SELECT * from wcmchannelsyn where srcchannel in (SELECT channelId from exchange_channel) and tochannel in (SELECT channelId from exchange_channel);
+-- 存放路径
+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);
+-- 多余模板
+INSERT INTO exchange_template SELECT * from wcmtemplate where rootid = 0 or rootid in (SELECT siteId from exchange_website);
+-- 模板变量
+INSERT INTO exchange_templateargument SELECT * from wcmtemplateargument where TEMPLATEID in (SELECT TEMPID from exchange_template);
+-- 模板栏目绑定关系
+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);
+-- 嵌套模板信息
+INSERT INTO exchange_templatenest SELECT * from wcmtemplatenest WHERE (templateId in (SELECT TEMPID from exchange_template)) and (nestedtemplateId in (SELECT TEMPID from exchange_template));
+-- 模板引用信息
+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);
+-- 栏目绑定的视图
+INSERT INTO exchange_metaviewemployer SELECT * from xwcmmetaviewemployer where CHANNELID in (SELECT CHANNELID from exchange_channel);
+-- 视图信息
+INSERT INTO exchange_viewinfo SELECT * from xwcmviewinfo where VIEWINFOID in (SELECT VIEWID from exchange_metaviewemployer);
+-- 视图字段信息
+INSERT INTO exchange_viewfieldinfo SELECT * from xwcmviewfieldinfo where VIEWID in (SELECT viewinfoid from exchange_viewinfo);
+INSERT INTO exchange_metaviewfieldgroup SELECT * from xwcmmetaviewfieldgroup where metaviewid in (SELECT viewinfoid from exchange_viewinfo);
+-- 元数据表信息
+INSERT INTO exchange_tableinfo SELECT * from xwcmtableinfo where TABLEINFOID in (SELECT MAINTABLEID from exchange_viewinfo);
+INSERT INTO exchange_dbfieldinfo SELECT * from xwcmdbfieldinfo where TABLEID in (SELECT TABLEINFOID from exchange_tableinfo);
+-- --------数据记录
+INSERT INTO exchange_chnldoc SELECT * from wcmchnldoc WHERE CHNLID in (SELECT CHANNELID from exchange_channel);
+-- exchange_chnldoc
+INSERT INTO exchange_document SELECT * from wcmdocument WHERE docchannel in (SELECT CHANNELID from exchange_channel);
+
+-- xwcmmaterialquote记录
+INSERT INTO exchange_materialquote SELECT * from xwcmmaterialquote WHERE DOCID in (SELECT DOCID from wcmdocument);
+-- xwcmmaterial记录
+INSERT INTO exchange_material SELECT * from xwcmmaterial WHERE materialId in (SELECT materialId from exchange_materialquote);
+-- metatable
+-- SELECT CONCAT('DROP TABLE IF EXISTS exchange_metatable',TABLENAME,';') from exchange_tableinfo;
+-- SELECT CONCAT('create table exchange_metatable',TABLENAME,' like wcmmetatable',TABLENAME ,';') from exchange_tableinfo;
+-- SELECT CONCAT('INSERT INTO exchange_metatable',TABLENAME,' select * from wcmmetatable',TABLENAME ,' where metadataId in (select docid from exchange_document);') from exchange_tableinfo;
+

+ 101 - 0
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city2/00_Preprocessing.sql

@@ -0,0 +1,101 @@
+-- 删除不好,不能在原库运行,改用创建中间表的方式,减小迁移数据量,加速迁移
+-- 需求场景:按站点迁移一个节点,须保留的站点id人工整理
+
+-- 创建所需的中间表
+drop table if exists exchange_appendix;
+create table exchange_appendix like wcmappendix;
+drop table if exists exchange_channel;
+create table exchange_channel like wcmchannel;
+drop table if exists exchange_channelchildindexquote;
+create table exchange_channelchildindexquote like wcmchannelchildindexquote;
+drop table if exists exchange_channelsyn;
+create table exchange_channelsyn like wcmchannelsyn;
+drop table if exists exchange_chnldoc;
+create table exchange_chnldoc like wcmchnldoc;
+drop table if exists exchange_document;
+create table exchange_document like wcmdocument;
+drop table if exists exchange_folderpublishconfig;
+create table exchange_folderpublishconfig like wcmfolderpublishconfig;
+drop table if exists exchange_template;
+create table exchange_template like wcmtemplate;
+drop table if exists exchange_templateargument;
+create table exchange_templateargument like wcmtemplateargument;
+drop table if exists exchange_templateemploy;
+create table exchange_templateemploy like wcmtemplateemploy;
+drop table if exists exchange_templatenest;
+create table exchange_templatenest like wcmtemplatenest;
+drop table if exists exchange_templatequote;
+create table exchange_templatequote like wcmtemplatequote;
+drop table if exists exchange_website;
+create table exchange_website like wcmwebsite;
+drop table if exists exchange_classinfo;
+create table exchange_classinfo like xwcmclassinfo;
+drop table if exists exchange_classinfoview;
+create table exchange_classinfoview like xwcmclassinfoview;
+drop table if exists exchange_dbfieldinfo;
+create table exchange_dbfieldinfo like xwcmdbfieldinfo;
+drop table if exists exchange_material;
+create table exchange_material like xwcmmaterial;
+drop table if exists exchange_materialquote;
+create table exchange_materialquote like xwcmmaterialquote;
+drop table if exists exchange_metaviewemployer;
+create table exchange_metaviewemployer like xwcmmetaviewemployer;
+drop table if exists exchange_metaviewfieldgroup;
+create table exchange_metaviewfieldgroup like xwcmmetaviewfieldgroup;
+drop table if exists exchange_tableinfo;
+create table exchange_tableinfo like xwcmtableinfo;
+drop table if exists exchange_viewfieldinfo;
+create table exchange_viewfieldinfo like xwcmviewfieldinfo;
+drop table if exists exchange_viewinfo;
+create table exchange_viewinfo like xwcmviewinfo;
+
+INSERT INTO exchange_website SELECT  * from wcmwebsite where siteid in (
+135,139,145,146,147,148,149,152,153,156,157,159,161,164,165,166,168,169,171,172,175,176,177,179,180,182,187,189,190,191,196,199,200,201,202,204,205,206,208,209,210,212,213,214,218,221,222,224,225,226,227,228,229,230,231,232,233,234,236,237,238,239,240,241,242,244,245,246,247,248,249,250,251,252,253,256,257,258,259,261,265,266,267,268,270,271,273,274,275,276,277,278,281,282,283,284,285,286,293,294,295,296,300,301,302,303,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,322,323,324,325,326,327,329,330,331,332,333,336,337,338,339,340,335,328,280,279,272,264,263,260,254,243,223
+);
+-- 修复部分站点站点不显示问题
+UPDATE exchange_website set MEDIATYPE = 1;
+-- 删除多余栏目
+INSERT INTO exchange_channel SELECT * from wcmchannel where siteId in (SELECT siteId from exchange_website) and status >= 0;
+-- 栏目模板触发发布关联关系
+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);
+-- 文档分发关系
+INSERT INTO exchange_channelsyn SELECT * from wcmchannelsyn where srcchannel in (SELECT channelId from exchange_channel) and tochannel in (SELECT channelId from exchange_channel);
+-- 存放路径
+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);
+-- 多余模板
+INSERT INTO exchange_template SELECT * from wcmtemplate where rootid = 0 or rootid in (SELECT siteId from exchange_website);
+-- 模板变量
+INSERT INTO exchange_templateargument SELECT * from wcmtemplateargument where TEMPLATEID in (SELECT TEMPID from exchange_template);
+-- 模板栏目绑定关系
+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);
+-- 嵌套模板信息
+INSERT INTO exchange_templatenest SELECT * from wcmtemplatenest WHERE (templateId in (SELECT TEMPID from exchange_template)) and (nestedtemplateId in (SELECT TEMPID from exchange_template));
+-- 模板引用信息
+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);
+-- 栏目绑定的视图
+INSERT INTO exchange_metaviewemployer SELECT * from xwcmmetaviewemployer where CHANNELID in (SELECT CHANNELID from exchange_channel);
+-- 视图信息
+INSERT INTO exchange_viewinfo SELECT * from xwcmviewinfo where VIEWINFOID in (SELECT VIEWID from exchange_metaviewemployer);
+-- 视图字段信息
+INSERT INTO exchange_viewfieldinfo SELECT * from xwcmviewfieldinfo where VIEWID in (SELECT viewinfoid from exchange_viewinfo);
+INSERT INTO exchange_metaviewfieldgroup SELECT * from xwcmmetaviewfieldgroup where metaviewid in (SELECT viewinfoid from exchange_viewinfo);
+-- 元数据表信息
+INSERT INTO exchange_tableinfo SELECT * from xwcmtableinfo where TABLEINFOID in (SELECT MAINTABLEID from exchange_viewinfo);
+INSERT INTO exchange_dbfieldinfo SELECT * from xwcmdbfieldinfo where TABLEID in (SELECT TABLEINFOID from exchange_tableinfo);
+-- --------数据记录
+INSERT INTO exchange_chnldoc SELECT * from wcmchnldoc WHERE CHNLID in (SELECT CHANNELID from wcmchannel);
+-- exchange_chnldoc
+INSERT INTO exchange_document SELECT * from wcmdocument WHERE docchannel in (SELECT CHANNELID from wcmchannel);
+
+-- xwcmmaterialquote记录
+INSERT INTO exchange_materialquote SELECT * from xwcmmaterialquote WHERE DOCID in (SELECT DOCID from wcmdocument);
+-- xwcmmaterial记录
+INSERT INTO exchange_material SELECT * from xwcmmaterial WHERE materialId in (SELECT materialId from exchange_materialquote);
+
+
+-- metatable
+-- SELECT CONCAT('DROP TABLE IF EXISTS exchange_metatable',TABLENAME,';') from exchange_tableinfo;
+-- SELECT CONCAT('create table exchange_metatable',TABLENAME,' like wcmmetatable',TABLENAME ,';') from exchange_tableinfo;
+-- SELECT CONCAT('INSERT INTO exchange_metatable',TABLENAME,' select * from wcmmetatable',TABLENAME ,' where metadataId in (select docid from exchange_document);') from exchange_tableinfo;
+
+

+ 11 - 0
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city2/00_alter_metadata.sql

@@ -0,0 +1,11 @@
+-- 大表删除、修改某些字段以便添加默认字段能够顺利进行
+DELETE FROM xwcmdbfieldinfo WHERE TABLENAME = 'GovInfo' AND FIELDNAME = 'planpubtime';
+DELETE FROM xwcmviewfieldinfo WHERE TABLENAME = 'GovInfo' AND DBFIELDNAME = 'planpubtime';
+DELETE FROM xwcmdbfieldinfo WHERE TABLENAME = 'GovInfo' AND FIELDNAME = 'CMyCrUser';
+DELETE FROM xwcmviewfieldinfo WHERE TABLENAME = 'GovInfo' AND DBFIELDNAME = 'CMyCrUser';
+DELETE FROM xwcmdbfieldinfo WHERE TABLENAME = 'GovInfo' AND FIELDNAME = 'STATUSFORBS';
+DELETE FROM xwcmviewfieldinfo WHERE TABLENAME = 'GovInfo' AND DBFIELDNAME = 'STATUSFORBS';
+
+alter table wcmmetatableGovInfo drop column planpubtime,
+                                drop column CMyCrUser,
+																drop column STATUSFORBS

+ 99 - 0
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city3/00_Preprocessing.sql

@@ -0,0 +1,99 @@
+-- 删除不好,不能在原库运行,改用创建中间表的方式,减小迁移数据量,加速迁移
+-- 需求场景:按站点迁移一个节点,须保留的站点id人工整理
+
+-- 创建所需的中间表
+drop table if exists exchange_appendix;
+create table exchange_appendix like wcmappendix;
+drop table if exists exchange_channel;
+create table exchange_channel like wcmchannel;
+drop table if exists exchange_channelchildindexquote;
+create table exchange_channelchildindexquote like wcmchannelchildindexquote;
+drop table if exists exchange_channelsyn;
+create table exchange_channelsyn like wcmchannelsyn;
+drop table if exists exchange_chnldoc;
+create table exchange_chnldoc like wcmchnldoc;
+drop table if exists exchange_document;
+create table exchange_document like wcmdocument;
+drop table if exists exchange_folderpublishconfig;
+create table exchange_folderpublishconfig like wcmfolderpublishconfig;
+drop table if exists exchange_template;
+create table exchange_template like wcmtemplate;
+drop table if exists exchange_templateargument;
+create table exchange_templateargument like wcmtemplateargument;
+drop table if exists exchange_templateemploy;
+create table exchange_templateemploy like wcmtemplateemploy;
+drop table if exists exchange_templatenest;
+create table exchange_templatenest like wcmtemplatenest;
+drop table if exists exchange_templatequote;
+create table exchange_templatequote like wcmtemplatequote;
+drop table if exists exchange_website;
+create table exchange_website like wcmwebsite;
+drop table if exists exchange_classinfo;
+create table exchange_classinfo like xwcmclassinfo;
+drop table if exists exchange_classinfoview;
+create table exchange_classinfoview like xwcmclassinfoview;
+drop table if exists exchange_dbfieldinfo;
+create table exchange_dbfieldinfo like xwcmdbfieldinfo;
+drop table if exists exchange_material;
+create table exchange_material like xwcmmaterial;
+drop table if exists exchange_materialquote;
+create table exchange_materialquote like xwcmmaterialquote;
+drop table if exists exchange_metaviewemployer;
+create table exchange_metaviewemployer like xwcmmetaviewemployer;
+drop table if exists exchange_metaviewfieldgroup;
+create table exchange_metaviewfieldgroup like xwcmmetaviewfieldgroup;
+drop table if exists exchange_tableinfo;
+create table exchange_tableinfo like xwcmtableinfo;
+drop table if exists exchange_viewfieldinfo;
+create table exchange_viewfieldinfo like xwcmviewfieldinfo;
+drop table if exists exchange_viewinfo;
+create table exchange_viewinfo like xwcmviewinfo;
+
+INSERT INTO exchange_website SELECT  * from wcmwebsite where siteid in (
+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
+);
+-- 修复部分站点站点不显示问题
+UPDATE exchange_website set MEDIATYPE = 1;
+-- 删除多余栏目
+INSERT INTO exchange_channel SELECT * from wcmchannel where siteId in (SELECT siteId from exchange_website) and status >= 0;
+-- 栏目模板触发发布关联关系
+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);
+-- 文档分发关系
+INSERT INTO exchange_channelsyn SELECT * from wcmchannelsyn where srcchannel in (SELECT channelId from exchange_channel) and tochannel in (SELECT channelId from exchange_channel);
+-- 存放路径
+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);
+-- 多余模板
+INSERT INTO exchange_template SELECT * from wcmtemplate where rootid = 0 or rootid in (SELECT siteId from exchange_website);
+-- 模板变量
+INSERT INTO exchange_templateargument SELECT * from wcmtemplateargument where TEMPLATEID in (SELECT TEMPID from exchange_template);
+-- 模板栏目绑定关系
+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);
+-- 嵌套模板信息
+INSERT INTO exchange_templatenest SELECT * from wcmtemplatenest WHERE (templateId in (SELECT TEMPID from exchange_template)) and (nestedtemplateId in (SELECT TEMPID from exchange_template));
+-- 模板引用信息
+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);
+-- 栏目绑定的视图
+INSERT INTO exchange_metaviewemployer SELECT * from xwcmmetaviewemployer where CHANNELID in (SELECT CHANNELID from exchange_channel);
+-- 视图信息
+INSERT INTO exchange_viewinfo SELECT * from xwcmviewinfo where VIEWINFOID in (SELECT VIEWID from exchange_metaviewemployer);
+-- 视图字段信息
+INSERT INTO exchange_viewfieldinfo SELECT * from xwcmviewfieldinfo where VIEWID in (SELECT viewinfoid from exchange_viewinfo);
+INSERT INTO exchange_metaviewfieldgroup SELECT * from xwcmmetaviewfieldgroup where metaviewid in (SELECT viewinfoid from exchange_viewinfo);
+-- 元数据表信息
+INSERT INTO exchange_tableinfo SELECT * from xwcmtableinfo where TABLEINFOID in (SELECT MAINTABLEID from exchange_viewinfo);
+INSERT INTO exchange_dbfieldinfo SELECT * from xwcmdbfieldinfo where TABLEID in (SELECT TABLEINFOID from exchange_tableinfo);
+-- --------数据记录
+INSERT INTO exchange_chnldoc SELECT * from wcmchnldoc WHERE CHNLID in (SELECT CHANNELID from exchange_channel);
+-- exchange_chnldoc
+INSERT INTO exchange_document SELECT * from wcmdocument WHERE docchannel in (SELECT CHANNELID from exchange_channel);
+
+-- xwcmmaterialquote记录
+INSERT INTO exchange_materialquote SELECT * from xwcmmaterialquote WHERE DOCID in (SELECT DOCID from wcmdocument);
+-- xwcmmaterial记录
+INSERT INTO exchange_material SELECT * from xwcmmaterial WHERE materialId in (SELECT materialId from exchange_materialquote);
+
+
+-- SELECT CONCAT('DROP TABLE IF EXISTS exchange_metatable',TABLENAME,';') from exchange_tableinfo;
+-- SELECT CONCAT('create table exchange_metatable',TABLENAME,' like wcmmetatable',TABLENAME ,';') from exchange_tableinfo;
+-- SELECT CONCAT('INSERT INTO exchange_metatable',TABLENAME,' select * from wcmmetatable',TABLENAME ,' where metadataId in (select docid from exchange_document);') from exchange_tableinfo;
+

+ 1 - 0
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city5/00_Preprocessing.sql

@@ -93,4 +93,5 @@ alter table wcmmetatableoriginaldocument
     drop column organcat,
     drop column IntroPage,
     drop column SysTime,
+    drop column _MASK_FROM_V2,
     drop column Scm;

+ 120 - 0
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city6/00_Preprocessing.sql

@@ -0,0 +1,120 @@
+-- 删除不好,不能在原库运行,改用创建中间表的方式,减小迁移数据量,加速迁移
+-- 需求场景:按站点迁移一个节点,须保留的站点id人工整理
+
+-- 创建所需的中间表
+drop table if exists exchange_appendix;
+create table exchange_appendix like wcmappendix;
+drop table if exists exchange_channel;
+create table exchange_channel like wcmchannel;
+drop table if exists exchange_channelchildindexquote;
+create table exchange_channelchildindexquote like wcmchannelchildindexquote;
+drop table if exists exchange_channelsyn;
+create table exchange_channelsyn like wcmchannelsyn;
+drop table if exists exchange_chnldoc;
+create table exchange_chnldoc like wcmchnldoc;
+drop table if exists exchange_document;
+create table exchange_document like wcmdocument;
+drop table if exists exchange_folderpublishconfig;
+create table exchange_folderpublishconfig like wcmfolderpublishconfig;
+drop table if exists exchange_template;
+create table exchange_template like wcmtemplate;
+drop table if exists exchange_templateargument;
+create table exchange_templateargument like wcmtemplateargument;
+drop table if exists exchange_templateemploy;
+create table exchange_templateemploy like wcmtemplateemploy;
+drop table if exists exchange_templatenest;
+create table exchange_templatenest like wcmtemplatenest;
+drop table if exists exchange_templatequote;
+create table exchange_templatequote like wcmtemplatequote;
+drop table if exists exchange_website;
+create table exchange_website like wcmwebsite;
+drop table if exists exchange_classinfo;
+create table exchange_classinfo like xwcmclassinfo;
+drop table if exists exchange_classinfoview;
+create table exchange_classinfoview like xwcmclassinfoview;
+drop table if exists exchange_dbfieldinfo;
+create table exchange_dbfieldinfo like xwcmdbfieldinfo;
+drop table if exists exchange_material;
+create table exchange_material like xwcmmaterial;
+drop table if exists exchange_materialquote;
+create table exchange_materialquote like xwcmmaterialquote;
+drop table if exists exchange_metaviewemployer;
+create table exchange_metaviewemployer like xwcmmetaviewemployer;
+drop table if exists exchange_metaviewfieldgroup;
+create table exchange_metaviewfieldgroup like xwcmmetaviewfieldgroup;
+drop table if exists exchange_tableinfo;
+create table exchange_tableinfo like xwcmtableinfo;
+drop table if exists exchange_viewfieldinfo;
+create table exchange_viewfieldinfo like xwcmviewfieldinfo;
+drop table if exists exchange_viewinfo;
+create table exchange_viewinfo like xwcmviewinfo;
+
+INSERT INTO exchange_website SELECT  * from wcmwebsite where siteid in (
+328,392,332,379,350,341,257,287,289,372,177,217,319,382,349,329,307,317,326,252,383,304,303,369,313,280,264,256,380,352,141,344,267,373,193,188,269,258,358,279,345,312,316,273,261,192,359,140,142,325,301,283,322,388,254,324,315,300,173,262,346,263,137,375,309,334,386,216,268,327,333,293,275,305,351,348,282,308,368,255,387,302,318,163,311,278,271,331,310,265,374,340,272,371,296,260,249,339,335,299,248,274,355,215,253,384,277,290,181,143,198,242,377,259,323,353,285,366,378,314,266,363,336,288,292,284,286,294,276,295,306,298,364,270,390,376,245,367,162,250,337
+);
+-- 修复部分站点站点不显示问题
+UPDATE exchange_website set MEDIATYPE = 1;
+-- 删除多余栏目
+INSERT INTO exchange_channel SELECT * from wcmchannel where siteId in (SELECT siteId from exchange_website) and status >= 0;
+-- 栏目模板触发发布关联关系
+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);
+-- 文档分发关系
+INSERT INTO exchange_channelsyn SELECT * from wcmchannelsyn where srcchannel in (SELECT channelId from exchange_channel) and tochannel in (SELECT channelId from exchange_channel);
+-- 存放路径
+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);
+-- 多余模板
+INSERT INTO exchange_template SELECT * from wcmtemplate where rootid = 0 or rootid in (SELECT siteId from exchange_website);
+-- 模板变量
+INSERT INTO exchange_templateargument SELECT * from wcmtemplateargument where TEMPLATEID in (SELECT TEMPID from exchange_template);
+-- 模板栏目绑定关系
+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);
+-- 嵌套模板信息
+INSERT INTO exchange_templatenest SELECT * from wcmtemplatenest WHERE (templateId in (SELECT TEMPID from exchange_template)) and (nestedtemplateId in (SELECT TEMPID from exchange_template));
+-- 模板引用信息
+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);
+-- 栏目绑定的视图
+INSERT INTO exchange_metaviewemployer SELECT * from xwcmmetaviewemployer where CHANNELID in (SELECT CHANNELID from exchange_channel);
+-- 视图信息
+INSERT INTO exchange_viewinfo SELECT * from xwcmviewinfo where VIEWINFOID in (SELECT VIEWID from exchange_metaviewemployer);
+-- 视图字段信息
+INSERT INTO exchange_viewfieldinfo SELECT * from xwcmviewfieldinfo where VIEWID in (SELECT viewinfoid from exchange_viewinfo);
+INSERT INTO exchange_metaviewfieldgroup SELECT * from xwcmmetaviewfieldgroup where metaviewid in (SELECT viewinfoid from exchange_viewinfo);
+-- 元数据表信息
+INSERT INTO exchange_tableinfo SELECT * from xwcmtableinfo where TABLEINFOID in (SELECT MAINTABLEID from exchange_viewinfo);
+INSERT INTO exchange_dbfieldinfo SELECT * from xwcmdbfieldinfo where TABLEID in (SELECT TABLEINFOID from exchange_tableinfo);
+-- --------数据记录
+INSERT INTO exchange_chnldoc SELECT * from wcmchnldoc WHERE CHNLID in (SELECT CHANNELID from exchange_channel);
+-- exchange_chnldoc
+INSERT INTO exchange_document SELECT * from wcmdocument WHERE docchannel in (SELECT CHANNELID from exchange_channel);
+
+-- xwcmmaterialquote记录
+INSERT INTO exchange_materialquote SELECT * from xwcmmaterialquote WHERE DOCID in (SELECT DOCID from exchange_document);
+-- xwcmmaterial记录
+INSERT INTO exchange_material SELECT * from xwcmmaterial WHERE materialId in (SELECT materialId from exchange_materialquote);
+-- metatable
+DROP TABLE IF EXISTS exchange_metatableldr;
+DROP TABLE IF EXISTS exchange_metatableGovInfo;
+DROP TABLE IF EXISTS exchange_metatablezxft;
+DROP TABLE IF EXISTS exchange_metatablelyd;
+DROP TABLE IF EXISTS exchange_metatabledlgg;
+DROP TABLE IF EXISTS exchange_metatableGXZZZS;
+DROP TABLE IF EXISTS exchange_metatabletjsj;
+create table exchange_metatableldr like wcmmetatableldr;
+create table exchange_metatableGovInfo like wcmmetatableGovInfo;
+create table exchange_metatablezxft like wcmmetatablezxft;
+create table exchange_metatablelyd like wcmmetatablelyd;
+create table exchange_metatabledlgg like wcmmetatabledlgg;
+create table exchange_metatableGXZZZS like wcmmetatableGXZZZS;
+create table exchange_metatabletjsj like wcmmetatabletjsj;
+INSERT INTO exchange_metatableldr select * from wcmmetatableldr where metadataId in (select docid from exchange_chnldoc);
+INSERT INTO exchange_metatableGovInfo select * from wcmmetatableGovInfo where metadataId in (select docid from exchange_chnldoc);
+INSERT INTO exchange_metatablezxft select * from wcmmetatablezxft where metadataId in (select docid from exchange_chnldoc);
+INSERT INTO exchange_metatablelyd select * from wcmmetatablelyd where metadataId in (select docid from exchange_chnldoc);
+INSERT INTO exchange_metatabledlgg select * from wcmmetatabledlgg where metadataId in (select docid from exchange_chnldoc);
+INSERT INTO exchange_metatableGXZZZS select * from wcmmetatableGXZZZS where metadataId in (select docid from exchange_chnldoc);
+INSERT INTO exchange_metatabletjsj select * from wcmmetatabletjsj where metadataId in (select docid from exchange_chnldoc);
+
+SELECT CONCAT('DROP TABLE IF EXISTS exchange_metatable',TABLENAME,';') from exchange_tableinfo;
+SELECT CONCAT('create table exchange_metatable',TABLENAME,' like wcmmetatable',TABLENAME ,';') from exchange_tableinfo;
+SELECT CONCAT('INSERT INTO exchange_metatable',TABLENAME,' select * from wcmmetatable',TABLENAME ,' where metadataId in (select docid from exchange_document);') from exchange_tableinfo;
+

+ 6 - 0
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city6/00_alter_metadata.sql

@@ -0,0 +1,6 @@
+-- 大表删除、修改某些字段以便添加默认字段能够顺利进行
+update xwcmdbfieldinfo SET DBLENGTH = 3000 WHERE TABLENAME = 'GovInfo' AND FIELDNAME = 'RelPhoto';
+update xwcmviewfieldinfo SET DBLENGTH = 3000 WHERE TABLENAME = 'GovInfo' AND DBFIELDNAME = 'RelPhoto';
+
+alter table wcmmetatableGovInfo
+  MODIFY COLUMN `RelPhoto`  varchar(3000) NULL DEFAULT ''

+ 34 - 0
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city6/00_rename_table.sql

@@ -0,0 +1,34 @@
+
+rename table exchange_appendix to wcmappendix;
+rename table exchange_channel to wcmchannel;
+rename table exchange_channelchildindexquote to wcmchannelchildindexquote;
+rename table exchange_channelsyn to wcmchannelsyn;
+rename table exchange_chnldoc to wcmchnldoc;
+rename table exchange_document to wcmdocument;
+rename table exchange_folderpublishconfig to wcmfolderpublishconfig;
+rename table exchange_template to wcmtemplate;
+rename table exchange_templateargument to wcmtemplateargument;
+rename table exchange_templateemploy to wcmtemplateemploy;
+rename table exchange_templatenest to wcmtemplatenest;
+rename table exchange_templatequote to wcmtemplatequote;
+rename table exchange_website to wcmwebsite;
+rename table exchange_classinfo to xwcmclassinfo;
+rename table exchange_classinfoview to xwcmclassinfoview;
+rename table exchange_dbfieldinfo to xwcmdbfieldinfo;
+rename table exchange_material to xwcmmaterial;
+rename table exchange_materialquote to xwcmmaterialquote;
+rename table exchange_metaviewemployer to xwcmmetaviewemployer;
+rename table exchange_metaviewfieldgroup to xwcmmetaviewfieldgroup;
+rename table exchange_tableinfo to xwcmtableinfo;
+rename table exchange_viewfieldinfo to xwcmviewfieldinfo;
+rename table exchange_viewinfo to xwcmviewinfo;
+
+-- metatables
+rename table exchange_metatableldr to wcmmetatableldr;
+rename table exchange_metatableGovInfo to wcmmetatableGovInfo;
+rename table exchange_metatablezjdc to wcmmetatablezjdc;
+rename table exchange_metatablezxft to wcmmetatablezxft;
+rename table exchange_metatablelyd to wcmmetatablelyd;
+rename table exchange_metatabledlgg to wcmmetatabledlgg;
+rename table exchange_metatableGXZZZS to wcmmetatableGXZZZS;
+rename table exchange_metatabletjsj to wcmmetatabletjsj;

+ 108 - 0
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city7/00_Preprocessing.sql

@@ -0,0 +1,108 @@
+-- 删除不好,不能在原库运行,改用创建中间表的方式,减小迁移数据量,加速迁移
+-- 需求场景:按站点迁移一个节点,须保留的站点id人工整理
+
+-- 创建所需的中间表
+drop table if exists exchange_appendix;
+create table exchange_appendix like wcmappendix;
+drop table if exists exchange_channel;
+create table exchange_channel like wcmchannel;
+drop table if exists exchange_channelchildindexquote;
+create table exchange_channelchildindexquote like wcmchannelchildindexquote;
+drop table if exists exchange_channelsyn;
+create table exchange_channelsyn like wcmchannelsyn;
+drop table if exists exchange_chnldoc;
+create table exchange_chnldoc like wcmchnldoc;
+drop table if exists exchange_document;
+create table exchange_document like wcmdocument;
+drop table if exists exchange_folderpublishconfig;
+create table exchange_folderpublishconfig like wcmfolderpublishconfig;
+drop table if exists exchange_template;
+create table exchange_template like wcmtemplate;
+drop table if exists exchange_templateargument;
+create table exchange_templateargument like wcmtemplateargument;
+drop table if exists exchange_templateemploy;
+create table exchange_templateemploy like wcmtemplateemploy;
+drop table if exists exchange_templatenest;
+create table exchange_templatenest like wcmtemplatenest;
+drop table if exists exchange_templatequote;
+create table exchange_templatequote like wcmtemplatequote;
+drop table if exists exchange_website;
+create table exchange_website like wcmwebsite;
+drop table if exists exchange_classinfo;
+create table exchange_classinfo like xwcmclassinfo;
+drop table if exists exchange_classinfoview;
+create table exchange_classinfoview like xwcmclassinfoview;
+drop table if exists exchange_dbfieldinfo;
+create table exchange_dbfieldinfo like xwcmdbfieldinfo;
+drop table if exists exchange_material;
+drop table if exists exchange_metaviewemployer;
+create table exchange_metaviewemployer like xwcmmetaviewemployer;
+drop table if exists exchange_metaviewfieldgroup;
+create table exchange_metaviewfieldgroup like xwcmmetaviewfieldgroup;
+drop table if exists exchange_tableinfo;
+create table exchange_tableinfo like xwcmtableinfo;
+drop table if exists exchange_viewfieldinfo;
+create table exchange_viewfieldinfo like xwcmviewfieldinfo;
+drop table if exists exchange_viewinfo;
+create table exchange_viewinfo like xwcmviewinfo;
+
+INSERT INTO exchange_website SELECT  * from wcmwebsite where siteid in
+(112,11,12,15,18,20,21,22,23,24,25,26,29,30,32,33,34,36,38,39,40,41,43,49,52,57,58,59,60,61,62,63,65,67,68,69,73,74,75,76,79,83,85,86,89,91,93,219,228,232,233,234,72,235,31,37,103,102,229,53,48,88,87,17,64,47,19,231,14,84);
+-- 修复部分站点站点不显示问题
+UPDATE exchange_website set MEDIATYPE = 1;
+-- 删除多余栏目
+INSERT INTO exchange_channel SELECT * from wcmchannel where siteId in (SELECT siteId from exchange_website) and status >= 0;
+-- 栏目模板触发发布关联关系
+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);
+-- 文档分发关系
+INSERT INTO exchange_channelsyn SELECT * from wcmchannelsyn where srcchannel in (SELECT channelId from exchange_channel) and tochannel in (SELECT channelId from exchange_channel);
+-- 存放路径
+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);
+-- 多余模板
+INSERT INTO exchange_template SELECT * from wcmtemplate where rootid = 0 or rootid in (SELECT siteId from exchange_website);
+-- 模板变量
+INSERT INTO exchange_templateargument SELECT * from wcmtemplateargument where TEMPLATEID in (SELECT TEMPID from exchange_template);
+-- 模板栏目绑定关系
+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);
+-- 嵌套模板信息
+INSERT INTO exchange_templatenest SELECT * from wcmtemplatenest WHERE (templateId in (SELECT TEMPID from exchange_template)) and (nestedtemplateId in (SELECT TEMPID from exchange_template));
+-- 模板引用信息
+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);
+-- 栏目绑定的视图
+INSERT INTO exchange_metaviewemployer SELECT * from xwcmmetaviewemployer where CHANNELID in (SELECT CHANNELID from exchange_channel);
+-- 视图信息
+INSERT INTO exchange_viewinfo SELECT * from xwcmviewinfo where VIEWINFOID in (SELECT VIEWID from exchange_metaviewemployer);
+-- 视图字段信息
+INSERT INTO exchange_viewfieldinfo SELECT * from xwcmviewfieldinfo where VIEWID in (SELECT viewinfoid from exchange_viewinfo);
+INSERT INTO exchange_metaviewfieldgroup SELECT * from xwcmmetaviewfieldgroup where metaviewid in (SELECT viewinfoid from exchange_viewinfo);
+-- 元数据表信息
+INSERT INTO exchange_tableinfo SELECT * from xwcmtableinfo where TABLEINFOID in (SELECT MAINTABLEID from exchange_viewinfo);
+INSERT INTO exchange_dbfieldinfo SELECT * from xwcmdbfieldinfo where TABLEID in (SELECT TABLEINFOID from exchange_tableinfo);
+-- --------数据记录
+INSERT INTO exchange_chnldoc SELECT * from wcmchnldoc WHERE CHNLID in (SELECT CHANNELID from exchange_channel);
+-- exchange_chnldoc
+INSERT INTO exchange_document SELECT * from wcmdocument WHERE DOCID in (SELECT DOCID from exchange_chnldoc);
+-- metatable
+
+DROP TABLE IF EXISTS exchange_metatableGovInfo;
+DROP TABLE IF EXISTS exchange_metatablefzbxzzfry;
+DROP TABLE IF EXISTS exchange_metatablefzbxzzfzt;
+DROP TABLE IF EXISTS exchange_metatablespzdgg;
+DROP TABLE IF EXISTS exchange_metatableyfbzt;
+DROP TABLE IF EXISTS exchange_metatablebloodStatus;
+create table exchange_metatableGovInfo like wcmmetatableGovInfo;
+create table exchange_metatablefzbxzzfry like wcmmetatablefzbxzzfry;
+create table exchange_metatablefzbxzzfzt like wcmmetatablefzbxzzfzt;
+create table exchange_metatablespzdgg like wcmmetatablespzdgg;
+create table exchange_metatableyfbzt like wcmmetatableyfbzt;
+create table exchange_metatablebloodStatus like wcmmetatablebloodStatus;
+INSERT INTO exchange_metatableGovInfo select * from wcmmetatableGovInfo where metadataId in (select docid from exchange_document);
+INSERT INTO exchange_metatablefzbxzzfry select * from wcmmetatablefzbxzzfry where metadataId in (select docid from exchange_document);
+INSERT INTO exchange_metatablefzbxzzfzt select * from wcmmetatablefzbxzzfzt where metadataId in (select docid from exchange_document);
+INSERT INTO exchange_metatablespzdgg select * from wcmmetatablespzdgg where metadataId in (select docid from exchange_document);
+INSERT INTO exchange_metatableyfbzt select * from wcmmetatableyfbzt where metadataId in (select docid from exchange_document);
+INSERT INTO exchange_metatablebloodStatus select * from wcmmetatablebloodStatus where metadataId in (select docid from exchange_document);
+-- SELECT CONCAT('DROP TABLE IF EXISTS exchange_metatable',TABLENAME,';') from exchange_tableinfo;
+-- SELECT CONCAT('create table exchange_metatable',TABLENAME,' like wcmmetatable',TABLENAME ,';') from exchange_tableinfo;
+-- SELECT CONCAT('INSERT INTO exchange_metatable',TABLENAME,' select * from wcmmetatable',TABLENAME ,' where metadataId in (select docid from exchange_document);') from exchange_tableinfo;
+

+ 34 - 0
TRS.WCM.Developer/贵州项目6个WCM节点迁移到海云/迁移前每个节点的特殊处理/city7/00_rename_table.sql

@@ -0,0 +1,34 @@
+
+rename table exchange_appendix to wcmappendix;
+rename table exchange_channel to wcmchannel;
+rename table exchange_channelchildindexquote to wcmchannelchildindexquote;
+rename table exchange_channelsyn to wcmchannelsyn;
+rename table exchange_chnldoc to wcmchnldoc;
+rename table exchange_document to wcmdocument;
+rename table exchange_folderpublishconfig to wcmfolderpublishconfig;
+rename table exchange_template to wcmtemplate;
+rename table exchange_templateargument to wcmtemplateargument;
+rename table exchange_templateemploy to wcmtemplateemploy;
+rename table exchange_templatenest to wcmtemplatenest;
+rename table exchange_templatequote to wcmtemplatequote;
+rename table exchange_website to wcmwebsite;
+rename table exchange_classinfo to xwcmclassinfo;
+rename table exchange_classinfoview to xwcmclassinfoview;
+rename table exchange_dbfieldinfo to xwcmdbfieldinfo;
+rename table exchange_metaviewemployer to xwcmmetaviewemployer;
+rename table exchange_metaviewfieldgroup to xwcmmetaviewfieldgroup;
+rename table exchange_tableinfo to xwcmtableinfo;
+rename table exchange_viewfieldinfo to xwcmviewfieldinfo;
+rename table exchange_viewinfo to xwcmviewinfo;
+
+-- metatables
+rename table exchange_metatableldr to wcmmetatableldr;
+rename table exchange_metatableGovInfo to wcmmetatableGovInfo;
+rename table exchange_metatablezjdc to wcmmetatablezjdc;
+rename table exchange_metatablezxft to wcmmetatablezxft;
+rename table exchange_metatablelyd to wcmmetatablelyd;
+rename table exchange_metatabledlgg to wcmmetatabledlgg;
+rename table exchange_metatableGXZZZS to wcmmetatableGXZZZS;
+rename table exchange_metatabletjsj to wcmmetatabletjsj;
+
+SELECT CONCAT('rename table exchange_metatable',TABLENAME,' to wcmmetatable',TABLENAME ,';') from exchange_tableinfo;