Explorar o código

优化迁移sql

xxy %!s(int64=6) %!d(string=hai) anos
pai
achega
e55e9530f7

+ 1 - 1
TRS.WCM.Developer/贵州项目/0_delete_redundance_data.sql

@@ -16,7 +16,7 @@ DELETE from wcmchannelsyn where tochannel not in (SELECT channelId from wcmchann
 DELETE from wcmfolderpublishconfig where FOLDERID not in (SELECT channelId from wcmchannel) and FOLDERTYPE = 101;
 DELETE from wcmfolderpublishconfig where FOLDERID not in (SELECT siteId from wcmwebsite) and FOLDERTYPE = 103;
 -- 多余模板
-DELETE from wcmtemplate where rootid not in (SELECT siteId from wcmwebsite);
+DELETE from wcmtemplate where rootid <> 0 and rootid not in (SELECT siteId from wcmwebsite);
 -- 模板变量
 DELETE from wcmtemplateargument where TEMPLATEID not in (SELECT TEMPID from wcmtemplate);
 -- 模板栏目绑定关系

+ 15 - 4
TRS.WCM.Developer/贵州项目/readme.md

@@ -2,6 +2,9 @@
 参见 http://wiki.devdemo.trs.net.cn/pages/viewpage.action?pageId=12027628
 
 ## 迁移方式(新)
+注:
+中间库:每个节点使用不同中间库,库名可以不限制
+mas中间库:库名固定为trs_data_migration_mas
 
 1. 数据准备与wiki中相同。中间库可以根据节点自己区分。
    * 将wiki中记录的表,元数据表以及mas表迁移到对应的中间库中。
@@ -12,6 +15,8 @@
         DELETE FROM xwcmmaterial WHERE MATERIALTYPE = 2 and MASID is NULL;
         #查询表中是否存在唯一建重复
         SELECT DOCID,CHNLID FROM wcmchnldoc GROUP BY DOCID,CHNLID HAVING COUNT(1) > 1;
+        create table t_chnldoc as SELECT MAX(RECID) as 'RECID',DOCID,CHNLID,count(1) datacount FROM wcmchnldoc GROUP BY DOCID,CHNLID HAVING COUNT(1) > 1 ;
+        DELETE FROM	wcmchnldoc WHERE recid IN(SELECT recid FROM t_chnldoc);
      ```
    
 2. 迁移站点,栏目,视图,模板等基本数据。(用户可以在新系统中增加角色,调整视图和模板)
@@ -46,10 +51,8 @@
     * 中间库,处理元数据表信息;需要先对迁移元数据表进行整理,将需要迁移的元数据表拷贝到中间库;
       * 执行存储过程update_data_dbfield.sql和update_data_table.sql,。中间库,删除多余字段元数据,添加默认的元数据字段
        ```sql
-         #获取起始的tabelinfo表的数据ID
-         SELECT prev_id from data_migration_log where table_name = 'xwcmtableinfo';
          # 注意该脚本结果为sql 脚本。需要复制脚本再执行一遍。
-         call update_data_table('_city4',迁移起始tabelinfoID);
+         call update_data_table('_city4',0);
        ```
       * 中间库,中间库修改元数据表名;
       ```sql
@@ -75,10 +78,17 @@
      ```
    * 中间库,执行迁移脚本
      ```sql 
-      call sp_city_data(节点ID)
+      call sp_city_data(节点ID);
      ```
    * 中间库,迁移附件  **注意必须要对迁移数据表建主键索引**
+     ```sql
+      ALTER TABLE `xwcmmaterial`
+        ADD PRIMARY KEY (`MATERIALID`);
+      ALTER TABLE `xwcmmaterialquote`
+        ADD INDEX (`MATERIALID`) USING BTREE ,
+        ADD INDEX (`DOCID`) USING BTREE ;
      ``` 
+    * mas中间库
       #mas数据迁移
       call sp_city_mas();
       
@@ -86,6 +96,7 @@
       call sp_city_appendix(节点ID, masID的偏移量);
      ```
    * 中间库,修改元数据中相关图片,相关视频字段不对
+   * masurl 例如:http://172.16.150.78/mas/openapi/pages.do?method=exPlay&appKey=gov&id=
      ```sql
        call update_data_relation_appendix(节点ID, masurl前缀, 起始tabelID,起始docId);
      ```