4_sp_city_n.sql 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. USE trs_data_migration;
  2. DROP PROCEDURE IF EXISTS sp_city_n;
  3. DELIMITER $$
  4. CREATE PROCEDURE sp_city_n(IN n INT)
  5. BEGIN
  6. # 每迁移一个wcm节点,@n 必须 +1
  7. SET @n = n;
  8. # 每个wcm节点,元数据表需要加上后缀,以区分同名元数据表
  9. SET @citySuffix = concat('_city', @n);
  10. # 支持断点续传,上一次迁移的最后一个 xx ID
  11. SET @prevSiteId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmwebsite'), 0);
  12. SET @prevChannelId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmchannel'), 0);
  13. SET @prevRecId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmchnldoc'), 0);
  14. SET @prevDocId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmdocument'), 0);
  15. SET @prevChannelSynId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmchannelsyn'), 0);
  16. SET @prevFolderPublishConfigId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmfolderpublishconfig'), 0);
  17. SET @prevTemplateId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmtemplate'), 0);
  18. SET @prevTemplateArgId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmtemplateargument'), 0);
  19. SET @prevTemplateEmployId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmtemplateemploy'), 0);
  20. SET @prevTemplateNestId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmtemplatenest'), 0);
  21. SET @prevTemplateQuoteId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmtemplatequote'), 0);
  22. SET @prevClassInfoId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmclassinfo'), 0);
  23. SET @prevClassInfoViewId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmclassinfoview'), 0);
  24. SET @prevFieldId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmdbfieldinfo'), 0);
  25. SET @prevMetaViewEmployerId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmmetaviewemployer'), 0);
  26. SET @prevTableInfoId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmtableinfo'), 0);
  27. SET @prevViewFieldInfoId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmviewfieldinfo'), 0);
  28. SET @prevViewId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmviewinfo'), 0);
  29. SET @prevMetaViewFieldGroupId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmmetaviewfieldgroup'), 0);
  30. SET @prevAppendixId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmappendix'), 0);
  31. # xx ID 偏移量,为了和海云系统中的 xx ID 错开一段距离
  32. SET @siteIdOffset = 100000 * @n;
  33. SET @viewIdOffset = 100000 * @n;
  34. SET @tableInfoIdOffset = 100000 * @n;
  35. SET @metaViewFieldGroupIdOffset = 100000 * @n;
  36. SET @classInfoViewIdOffset = 100000 * @n;
  37. SET @classInfoIdOffset = 100000 * @n;
  38. SET @fieldIdOffset = 1000000 * @n;
  39. SET @metaViewEmployerIdOffset = 100000 * @n;
  40. SET @viewFieldInfoIdOffset = 100000 * @n;
  41. SET @dbFieldIdOffset = 100000 * @n;
  42. SET @channelIdOffset = 1000000 * @n;
  43. SET @channelSynIdOffset = 1000000 * @n;
  44. SET @templateIdOffset = 1000000 * @n;
  45. SET @folderPublishConfigIdOffset = 1000000 * @n;
  46. SET @templateArgIdOffset = 1000000 * @n;
  47. SET @templateEmployIdOffset = 1000000 * @n;
  48. SET @templateNestIdOffset = 1000000 * @n;
  49. SET @templateQuoteIdOffset = 1000000 * @n;
  50. SET @appendixIdOffset = 10000000 * @n;
  51. SET @recIdOffset = 10000000 * @n;
  52. SET @docIdOffset = 10000000 * @n;
  53. call sp_data_migration_wcmappendix(@prevAppendixId, @appendixIdOffset, @docIdOffset);
  54. call sp_data_migration_wcmchannel(@prevChannelId, @siteIdOffset, @channelIdOffset);
  55. call sp_data_migration_wcmchannelchildindexquote(@templateIdOffset, @siteIdOffset, @channelIdOffset);
  56. call sp_data_migration_wcmchannelsyn(@prevChannelSynId, @channelSynIdOffset, @channelIdOffset);
  57. call sp_data_migration_wcmchnldoc(@prevRecId, @recIdOffset, @docIdOffset, @siteIdOffset, @channelIdOffset);
  58. call sp_data_migration_wcmdocument(@prevDocId, @prevDocId, @viewIdOffset, @siteIdOffset, @channelIdOffset);
  59. call sp_data_migration_wcmfolderpublishconfig(@prevFolderPublishConfigId, @folderPublishConfigIdOffset, @siteIdOffset, @channelIdOffset);
  60. call sp_data_migration_wcmtemplate(@prevTemplateId, @templateIdOffset, @siteIdOffset, @channelIdOffset);
  61. call sp_data_migration_wcmtemplateargument(@prevTemplateArgId, @templateArgIdOffset, @templateIdOffset, @siteIdOffset, @channelIdOffset);
  62. call sp_data_migration_wcmtemplateemploy(@prevTemplateEmployId, @templateEmployIdOffset, @templateIdOffset, @siteIdOffset, @channelIdOffset);
  63. call sp_data_migration_wcmtemplatenest(@prevTemplateNestId, @templateNestIdOffset);
  64. call sp_data_migration_wcmtemplatequote(@prevTemplateQuoteId, @templateQuoteIdOffset, @templateIdOffset, @siteIdOffset, @channelIdOffset);
  65. call sp_data_migration_wcmwebsite(@citySuffix, @prevSiteId, @siteIdOffset);
  66. call sp_data_migration_xwcmclassinfo(@prevClassInfoId, @classInfoIdOffset);
  67. call sp_data_migration_xwcmclassinfoview(@prevClassInfoViewId, @classInfoViewIdOffset, @classInfoIdOffset, @docIdOffset, @viewIdOffset);
  68. call sp_data_migration_xwcmdbfieldinfo(@citySuffix, @prevFieldId, @fieldIdOffset, @prevClassInfoId, @tableInfoIdOffset);
  69. call sp_data_migration_xwcmmetaviewemployer(@prevMetaViewEmployerId, @metaViewEmployerIdOffset, @viewIdOffset, @siteIdOffset, @channelIdOffset);
  70. call sp_data_migration_xwcmmetaviewfieldgroup(@prevMetaViewFieldGroupId, @metaViewFieldGroupIdOffset, @viewIdOffset);
  71. call sp_data_migration_xwcmtableinfo(@citySuffix, @prevTableInfoId, @tableInfoIdOffset);
  72. call sp_data_migration_xwcmviewfieldinfo(@citySuffix, @prevViewFieldInfoId, @viewFieldInfoIdOffset, @tableInfoIdOffset, @prevClassInfoId, @dbFieldIdOffset, @metaViewFieldGroupIdOffset, @viewIdOffset, @viewIdOffset);
  73. call sp_data_migration_xwcmviewinfo(@citySuffix, @prevViewId, @viewIdOffset, @tableInfoIdOffset);
  74. call sp_data_migration_wcmmetatable(@citySuffix, @prevTableInfoId, @prevDocId, @docIdOffset, @channelIdOffset);
  75. # 迁移 MAS 视频,6个wcm节点的视频是在一起的。可重复执行。
  76. # 支持断点续传,上一次迁移的最后一个 xx ID
  77. SET @prevMasId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'mas_masid'), 0);
  78. SET @prevMasVideoId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'mas_masvideo'), 0);
  79. SET @masIdOffset = 1000000;
  80. SET @masVideoIdOffset = 1000000;
  81. call trs_data_migration.sp_data_migration_masid(@prevMasId, @masIdOffset);
  82. call trs_data_migration.sp_data_migration_masvideo(@prevMasVideoId, @masVideoIdOffset);
  83. END $$
  84. DELIMITER ;