|
|
@@ -0,0 +1,93 @@
|
|
|
+USE trs_data_migration;
|
|
|
+
|
|
|
+SET GLOBAL log_bin_trust_function_creators = TRUE;
|
|
|
+DROP FUNCTION IF EXISTS data_migration_function;
|
|
|
+DELIMITER $$
|
|
|
+CREATE FUNCTION data_migration_function(n INT)
|
|
|
+ RETURNS VARCHAR(255)
|
|
|
+ BEGIN
|
|
|
+
|
|
|
+ use trs_hycloud_iip;
|
|
|
+
|
|
|
+ # 每迁移一个wcm节点,@n 必须 +1
|
|
|
+ SET @n = n;
|
|
|
+
|
|
|
+ # 每个wcm节点,元数据表需要加上后缀,以区分同名元数据表
|
|
|
+ SET @citySuffix = concat('_city', @n);
|
|
|
+
|
|
|
+ # 支持断点续传,上一次迁移的最后一个 xx ID
|
|
|
+ SET @prevSiteId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmwebsite'), 0);
|
|
|
+ SET @prevChannelId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmchannel'), 0);
|
|
|
+ SET @prevRecId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmchnldoc'), 0);
|
|
|
+ SET @prevDocId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmdocument'), 0);
|
|
|
+ SET @prevChannelSynId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmchannelsyn'), 0);
|
|
|
+ SET @prevFolderPublishConfigId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmfolderpublishconfig'), 0);
|
|
|
+ SET @prevTemplateId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmtemplate'), 0);
|
|
|
+ SET @prevTemplateArgId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmtemplateargument'), 0);
|
|
|
+ SET @prevTemplateEmployId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmtemplateemploy'), 0);
|
|
|
+ SET @prevTemplateNestId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmtemplatenest'), 0);
|
|
|
+ SET @prevTemplateQuoteId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmtemplatequote'), 0);
|
|
|
+ SET @prevClassInfoId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmclassinfo'), 0);
|
|
|
+ SET @prevClassInfoViewId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmclassinfoview'), 0);
|
|
|
+ SET @prevFieldId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmdbfieldinfo'), 0);
|
|
|
+ SET @prevMetaViewEmployerId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmmetaviewemployer'), 0);
|
|
|
+ SET @prevTableInfoId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmmetableinfo'), 0);
|
|
|
+ SET @prevViewFieldId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmviewfieldinfo'), 0);
|
|
|
+ SET @prevViewId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmviewinfo'), 0);
|
|
|
+ SET @prevMetaViewFieldGroupId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'xwcmmetaviewfieldgroup'), 0);
|
|
|
+ SET @prevAppendixId = ifnull((SELECT prev_id from trs_data_migration.data_migration_log where table_name = 'wcmappendix'), 0);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ # xx ID 偏移量,为了和海云系统中的 xx ID 错开一段距离
|
|
|
+ SET @siteIdOffset = 1000 * @n;
|
|
|
+ SET @channelIdOffset = 100000 * @n;
|
|
|
+ SET @channelSynIdOffset = 100000 * @n;
|
|
|
+ SET @templateIdOffset = 100000 * @n;
|
|
|
+ SET @recIdOffset = 10000000 * @n;
|
|
|
+ SET @docIdOffset = 10000000 * @n;
|
|
|
+ SET @viewIdOffset = 1000 * @n;
|
|
|
+ SET @folderPublishConfigIdOffset = 100000 * @n;
|
|
|
+ SET @templateArgIdOffset = 100000 * @n;
|
|
|
+ SET @templateEmployIdOffset = 1000000 * @n;
|
|
|
+ SET @templateNestIdOffset = 100000 * @n;
|
|
|
+ SET @templateQuoteIdOffset = 1000000 * @n;
|
|
|
+ SET @classInfoIdOffset = 10000 * @n;
|
|
|
+ SET @fieldIdOffset = 100000 * @n;
|
|
|
+ SET @tableInfoIdOffset = 1000 * @n;
|
|
|
+ SET @metaViewEmployerIdOffset = 100000 * @n;
|
|
|
+ SET @viewFieldIdOffset = 100000 * @n;
|
|
|
+ SET @dbFieldIdOffset = 100000 * @n;
|
|
|
+ SET @fieldGroupIdOffset = 1000 * @n;
|
|
|
+ SET @metaViewFieldGroupIdOffset = 1000 * @n;
|
|
|
+ SET @appendixIdOffset = 10000000 * @n;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ call p_data_migration_wcmappendix(@prevAppendixId, @appendixIdOffset, @docIdOffset);
|
|
|
+ call p_data_migration_wcmchannel(@prevChannelId, @siteIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_wcmchannelchildindexquote(@templateIdOffset, @siteIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_wcmchannelsyn(@prevChannelSynId, @channelSynIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_wcmchnldoc(@prevRecId, @recIdOffset, @prevDocId, @siteIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_wcmdocument(@prevDocId, @prevDocId, @viewIdOffset, @siteIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_wcmfolderpublishconfig(@prevFolderPublishConfigId, @folderPublishConfigIdOffset, @siteIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_wcmtemplate(@prevTemplateId, @templateIdOffset, @siteIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_wcmtemplateargument(@prevTemplateArgId, @templateArgIdOffset, @siteIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_wcmtemplateemploy(@prevTemplateEmployId, @templateEmployIdOffset, @templateIdOffset, @siteIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_wcmtemplatenest(@prevTemplateNestId, @templateNestIdOffset);
|
|
|
+ call p_data_migration_wcmtemplatequote(@prevTemplateQuoteId, @templateQuoteIdOffset, @templateIdOffset, @siteIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_wcmwebsite(@prevSiteId, @siteIdOffset);
|
|
|
+ call p_data_migration_xwcmclassinfo(@prevClassInfoId, @classInfoIdOffset);
|
|
|
+ call p_data_migration_xwcmclassinfoview(@prevClassInfoViewId, @classInfoIdOffset, @docIdOffset, @viewIdOffset);
|
|
|
+ call p_data_migration_xwcmdbinfo(@citySuffix, @prevFieldId, @fieldIdOffset, @prevClassInfoId, @tableInfoIdOffset);
|
|
|
+ call p_data_migration_xwcmmetaviewemployer(@prevMetaViewEmployerId, @metaViewEmployerIdOffset, @channelIdOffset);
|
|
|
+ call p_data_migration_xwcmmetaviewfieldgroup(@prevMetaViewFieldGroupId, @metaViewFieldGroupIdOffset, @viewIdOffset);
|
|
|
+ call p_data_migration_xwcmtableinfo(@citySuffix, @prevTableInfoId, @tableInfoIdOffset);
|
|
|
+ call p_data_migration_xwcmviewfieldinfo(@citySuffix, @prevViewFieldId, @viewFieldIdOffset, @tableInfoIdOffset, @prevClassInfoId, @dbFieldIdOffset, @fieldGroupIdOffset, @viewIdOffset, @viewIdOffset);
|
|
|
+ call p_data_migration_xwcmviewinfo(@citySuffix, @prevViewId, @viewIdOffset, @mainTableIdOffset);
|
|
|
+ call p_data_migration_wcmmetatable(@prevTableInfoId, @prevDocId, @docIdOffset, @channelIdOffset);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ RETURN 'OK';
|
|
|
+ END $$
|