Project

General

Profile

1
/*
2
 * TODO: restore any documents that were archived by the CN
3
 */
4

    
5

    
6
/* Ensure ALL previous revisions of docids 
7
 * that have been obsoleted_by something else
8
 * but still have current revisions 
9
 * do not also have archived=true flag set
10
 * (Avoids encountering this issue again)
11
 */
12

    
13
/* Check the numbers
14
 */
15
SELECT count(id.guid)
16
FROM xml_revisions x,
17
	identifier id,
18
	systemMetadata sm
19
WHERE x.docid = id.docid
20
AND x.rev = id.rev
21
AND id.guid = sm.guid
22
AND sm.obsoleted_by IS NOT null
23
AND sm.archived = 'true'
24
AND EXISTS (SELECT * from xml_documents xd WHERE xd.docid = x.docid);
25

    
26
/*Do the update
27
 */
28
UPDATE systemMetadata sm
29
SET sm.archived = false
30
FROM xml_revisions x,
31
	identifier id
32
WHERE x.docid = id.docid
33
AND x.rev = id.rev
34
AND id.guid = sm.guid
35
AND sm.obsoleted_by IS NOT null
36
AND sm.archived = 'true'
37
AND EXISTS (SELECT * from xml_documents xd WHERE xd.docid = x.docid);
38

    
39
/*
40
 * update the database version
41
 */
42
UPDATE db_version SET status=0;
43

    
44
INSERT INTO db_version (version, status, date_created) 
45
  VALUES ('2.4.0', 1, CURRENT_DATE);
(84-84/89)