Project

General

Profile

« Previous | Next » 

Revision 7334

add block for finding and updating records that should be marked as archived.
https://redmine.dataone.org/issues/3109

View differences:

src/system_metadata_revisions.sql
24 24
from systemmetadata sm, systemmetadata sm_s
25 25
where sm.guid = sm_s.obsoleted_by
26 26
and sm.obsoletes is null;
27

  
28
-- these are ones that should be marked as archived=true but are not
29
select sm. guid --count(sm.guid)
30
from systemmetadata sm, identifier id
31
where sm.guid = id.guid
32
and not exists (select * from xml_documents doc where doc.docid = id.docid and doc.rev = id.rev)
33
and sm.archived != true
34
and sm.obsoleted_by is null;
35

  
36
-- update them
37
BEGIN;
38
update systemmetadata sm
39
set sm.archived = true
40
from identifier id
41
where sm.guid = id.guid
42
and not exists (select * from xml_documents doc where doc.docid = id.docid and doc.rev = id.rev)
43
and sm.archived != true
44
and sm.obsoleted_by is null;
45
COMMIT;
46
--ROLLBACK;

Also available in: Unified diff