[关闭]
@myyzs 2019-04-01T08:14:41.000000Z 字数 2493 阅读 70

招商(cmsk)还原微信关联关系,绑定手机号,报表授权

数据还原


1.还原租户库及报表库

责任人:刘明
时间点:2019-03-29 23:00之前的数据
库:租户库+报表库

2.导入表

责任人:刘明
表(租户库):p_user_20190329,p_user_to_wx_20190329
表(报表库):rp_role_user_20190329
说明:将步骤1中的表还原到线上租户库(cmsk)和报表库

3.生成临时表

责任人:梅义
说明:通过步骤2中的备份表生成临时表,供数据还原使用

创建临时表(cmsk租户库):

  1. DROP TABLE IF EXISTS `erp_user_p_user_temp`;
  2. CREATE TABLE `erp_user_p_user_temp`(
  3. `user_code` VARCHAR(100) NOT NULL ,
  4. `old_user_id` INT(11) NOT NULL ,
  5. `new_user_id` INT(11) NOT NULL ,
  6. `new_openid` varchar(50) NOT NULL DEFAULT '',
  7. `wx_user_id` varchar(100) DEFAULT NULL,
  8. `user_tel` varchar(30) DEFAULT '' COMMENT '绑定手机号',
  9. INDEX `idx_openid` USING BTREE (`new_openid`) comment '',
  10. INDEX `old_user_id` USING BTREE(`old_user_id`) COMMENT '' ,
  11. INDEX `new_user_id` USING BTREE(`new_user_id`) COMMENT '' ,
  12. INDEX `wx_user_id` USING BTREE (`wx_user_id`) comment ''
  13. ) ENGINE = `InnoDB` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ROW_FORMAT = COMPACT COMMENT = '';

临时表插入数据:

  1. DELETE
  2. FROM
  3. p_user_to_wx_20190329
  4. WHERE
  5. user_id NOT IN(
  6. SELECT
  7. user_id
  8. FROM
  9. p_user_20190329
  10. );
  11. TRUNCATE table erp_user_p_user_temp;
  12. INSERT INTO erp_user_p_user_temp(
  13. user_code ,
  14. old_user_id ,
  15. new_user_id,
  16. new_openid,
  17. wx_user_id,
  18. user_tel
  19. ) SELECT
  20. pu.user_code AS user_code ,
  21. pu0329.user_id AS old_user_id ,
  22. pu.user_id AS new_user_id,
  23. pu.openid AS new_openid,
  24. ptwx0329.wx_user_id AS wx_user_id,
  25. pu0329.user_tel AS user_tel
  26. FROM
  27. p_user pu
  28. JOIN p_user_20190329 pu0329 ON pu0329.user_code = pu.user_code
  29. LEFT JOIN p_user_to_wx_20190329 ptwx0329 ON ptwx0329.user_id = pu0329.user_id

4.将临时表导入到报表库和配置库

责任人:刘明
说明:将处理过后的erp_user_p_user_temp导入到报表库和配置库,表名不变

5.还原p_user.user_tel

责任人:初良祥
说明:通过erp_user_p_user_temp,p_user还原p_user中user_tel

  1. update p_user a inner join erp_user_p_user_temp b on a.user_id=b.new_user_id set a.user_tel=b.user_tel;

6.还原p_user_to_wx

责任人:初良祥
说明:清空p_user_to_wx,通过erp_user_p_user_temp还原p_user_to_wx,还原后做一下“增量同步”

  1. TRUNCATE table p_user_to_wx;
  2. INSERT INTO p_user_to_wx (
  3. user_id,
  4. wx_user_id,
  5. create_time
  6. ) SELECT
  7. new_user_id,
  8. wx_user_id,
  9. now()
  10. FROM
  11. erp_user_p_user_temp
  12. WHERE
  13. wx_user_id != '' and wx_user_id is not null

7.还原wzs_user.user_tel

责任人:初良祥
说明:通过erp_user_p_user_temp还原wzs_user中user_tel

1、备份配置库wzs_user为wzs_user_20190401(刘明)

  1. update wzs_user a inner join wzs_user_to_tenant b on a.wzs_user_id=b.wzs_user_id
  2. inner join erp_user_p_user_temp c on b.openid=c.new_openid set a.user_tel=c.user_tel

8.还原rp_role_user

责任人:陆磊
说明:通过erp_user_p_user_temp,rp_role_user_20190329还原rp_role_user。注意只还原用户授权部门,部门授权不动

1、报表库rp_role_user 备份为 rp_role_user_20190401(刘明)
2、报表库rp_role_user_20190329 重命名为 rp_role_user(刘明)

  1. 3、执行SQL
  2. update `rp_role_user` as role_user, erp_user_p_user_temp as temp
  3. set user_id = temp.new_user_id
  4. where role_user.user_id = temp.old_user_id and role_user.member_type = 1;
  5. 4、客户检测数据无误,删除 rp_role_user_20190401
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注