Project

General

Profile

« Previous | Next » 

Revision 8600

add [partial] upgrade to the oracle script -- does not look for any records that the CN deleted because there are no Oracle-backed MNs at this time.

View differences:

src/upgrade-db-to-2.4.0-oracle.sql
1 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
/*
2 40
 * update the database version
3 41
 */
4 42
UPDATE db_version SET status=0;

Also available in: Unified diff