12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- use trs_data_migration;
- -- 迁移前执行call sp_data_migration_buildOffset(n);
- -- 为偏移量记录表插入数据。
- DROP PROCEDURE IF EXISTS sp_data_migration_buildOffset;
- DELIMITER $$
- CREATE PROCEDURE sp_data_migration_buildOffset(IN n SMALLINT(2))
- BEGIN
- -- 文档表
- set @offset = IFNULL((select `offset` from document_offset where `times` = n),0);
- IF @offset = 0 THEN
- SET @previous_id = IFNULL((select MAX(docId) from wcmdocument),0);
- SET @offset = IFNULL((select MAX(docid) from trs_hycloud_iip.wcmdocument),0);
- INSERT INTO document_offset values(n,@previous_id,@offset);
- END IF;
- -- 站点表
- set @offset = IFNULL((select `offset` from site_offset where `times` = n),0);
- IF @offset = 0 THEN
- SET @previous_id = IFNULL((select MAX(siteId) from wcmwebsite),0);
- SET @offset = IFNULL((select MAX(siteId) from trs_hycloud_iip.wcmwebsite),0);
- INSERT INTO site_offset values(n,@previous_id,@offset);
- END IF;
- -- 栏目表
- set @offset = IFNULL((select `offset` from channel_offset where `times` = n),0);
- IF @offset = 0 THEN
- SET @previous_id = IFNULL((select MAX(channelId) from wcmchannel),0);
- SET @offset = IFNULL((select MAX(channelId) from trs_hycloud_iip.wcmchannel),0);
- INSERT INTO channel_offset values(n,@previous_id,@offset);
- END IF;
- -- template表
- set @offset = IFNULL((select `offset` from template_offset where `times` = n),0);
- IF @offset = 0 THEN
- SET @previous_id = IFNULL((select MAX(tempId) from wcmtemplate),0);
- SET @offset = IFNULL((select MAX(tempId) from trs_hycloud_iip.wcmtemplate),0);
- INSERT INTO template_offset values(n,@previous_id,@offset);
- END IF;
- -- viewInfo表
- set @offset = IFNULL((select `offset` from viewInfo_offset where `times` = n),0);
- IF @offset = 0 THEN
- SET @previous_id = IFNULL((select MAX(viewInfoId) from xwcmviewinfo),0);
- SET @offset = IFNULL((select MAX(viewInfoId) from trs_hycloud_iip.xwcmviewinfo),0);
- INSERT INTO viewInfo_offset values(n,@previous_id,@offset);
- END IF;
- -- tableInfo表
- set @offset = IFNULL((select `offset` from tableInfo_offset where `times` = n),0);
- IF @offset = 0 THEN
- SET @previous_id = IFNULL((select MAX(tableInfoId) from xwcmtableinfo),0);
- SET @offset = IFNULL((select MAX(tableInfoId) from trs_hycloud_iip.xwcmtableinfo),0);
- INSERT INTO tableInfo_offset values(n,@previous_id,@offset);
- END IF;
- END $$
- DELIMITER ;
|