비참조 필드를 참조 필드로 마이그레이션
표시 이름을 문자열로 저장하는 대신 참조 필드에 sys_ids 수동으로 유지합니다.
마이그레이션할 테이블 결정
데이터 마이그레이션 프로세스를 시작하려면 다음 백그라운드 스크립트를 실행합니다. 이 스크립트는 보관 규칙 참조 마이그레이션 [sys_archive_ref_migration] 테이블에 직접 테이블 확장과 관련 보관된 기록 모두에 대한 마이그레이션 기록을 생성하여 유효한 테이블만 처리되도록 합니다.
var tables = GlideDBObjectManager.get().getAllExtensions(current.table);
for (i = 0; i < tables.size(); i++) {
var gr = new GlideRecord('sys_archive_ref_migration');
gr.addQuery('table', 'ar_' + tables.get(i));
gr.query();
if (!gr.next()) {
if (GlideTableDescriptor.isValid('ar_' + tables.get(i))) {
var gr2 = new GlideRecord("sys_archive_ref_migration");
gr2.initialize();
gr2.setValue('rule', current.sys_id);
gr2.setValue('table', 'ar_' + tables.get(i));
gr2.setValue('reference_migration_progress', 'waiting');
gr2.insert();
}
}
}
//Also get insert related records tables as well
var map = new GlideRecord('sys_archive');
map.addQuery('table', current.table);
map.query();
if (map.next()) {
var id = map.getValue('sys_id');
if (!(id === undefined)) {
var related = new GlideRecord('sys_archive_related');
related.addQuery('archive_map', id);
related.addQuery('action', 'archive');
related.query();
while (related.next()) {
if (!GlideTableDescriptor.isValid('ar_' + related.getValue('table'))) {
gs.log('Related Record table: ' + related.getValue('table') + ' not created yet');
continue;
}
var gr3 = new GlideRecord("sys_archive_ref_migration");
gr3.initialize();
gr3.setValue('rule', current.sys_id);
gr3.setValue('table', 'ar_' + related.getValue('table'));
gr3.setValue('reference_migration_progress', 'waiting');
gr3.insert();
}
}
}아카이브 참조 복사
마이그레이션 프로세스를 거치는 각 테이블에 대해 참조 복사본 보관(RefCopyJob) 작업은 참조 필드의 sys_id 식별하고 표시 값을 올바른 sys_id로 업데이트합니다. 타임스탬프가 동일한 기록이 10,000개 이상 없는 한 작업은 한 번에 10,000개의 기록을 구성합니다. 마이그레이션 진행은 보관된 타임스탬프에 의존합니다.
문자열에서 참조로 필드 유형 변경
보관 규칙과 연결된 테이블이 완전히 마이그레이션되면 ArchiveRefJob 작업이 실행됩니다. 이 작업은 보관 테이블의 sys_dictionary 유형을 문자열에서 참조로 변경합니다.
RefCopyJob 및 ArchiveRefJob에 대한 노드 오류 수정
이러한 작업이 실행되는 동안 노드 오류가 발생하면 데이터 마이그레이션 상태가 잘못된 상태로 유지됩니다. 실패하면 RefCopyJob 테이블이 마이그레이션 상태로 남을 수 있습니다. 이 조건은 sys_archive_ref_migration의 행이 이례적인 시간 동안 마이그레이션 상태에서 멈춰 있는지 확인하여 확인할 수 있습니다. 마이그레이션 에서대기 중 으로 특정 행 상태를 업데이트하고 RefCopyJob 작업이 다시 실행될 때 테이블에서 데이터 마이그레이션을 계속합니다.
노드가 조기에 종료될 때 ArchiveRefJob 도 노드가 실패할 수 있습니다. 테이블에 참조 필드인 필드가 있고 일부는 여전히 문자열 유형 필드인지 확인합니다. 필드 유형을 변경하는 도중에 작업이 중지되었을 수 있습니다. 프로세스를 다시 시작하는 백그라운드 스크립트에서 실행되도록 트리거 작업을 설정하여 이 조건을 해결할 수 있습니다.
GlideRecord trigger = new GlideRecord('sys_trigger');
trigger.initialize();
trigger.setValue('state', 0);
trigger.setValue('trigger_type', 0);
trigger.setValue('next_action', new GlideDateTime());
trigger.setValue('job_context', 'fcRuleId=' + ruleId);
trigger.setValue('name', 'Job Reference Migration' + ' Node - ' + new GlideClusterSynchronizer().getSystemID());
trigger.setValue('trigger_class', 'com.glide.db.auxiliary.job.ArchiveRefJob');
trigger.insert();