Revision 8642
Added by ben leinfelder over 10 years ago
upgrade-db-to-2.4.0-postgres.sql | ||
---|---|---|
9 | 9 |
* Then we know the current version should be restored |
10 | 10 |
*/ |
11 | 11 |
|
12 |
DROP TABLE IF EXISTS current_documents; |
|
13 |
CREATE TABLE current_documents ( |
|
14 |
guid text, |
|
15 |
obsoleted_by text |
|
16 |
); |
|
17 |
|
|
12 | 18 |
/* Find the most recent version by traversing system metadata |
13 | 19 |
* see: http://www.postgresql.org/docs/8.4/static/queries-with.html |
14 | 20 |
*/ |
15 |
DROP TABLE IF EXISTS current_documents;
|
|
21 |
INSERT INTO current_documents (guid, obsoleted_by)
|
|
16 | 22 |
WITH RECURSIVE q AS |
17 | 23 |
( |
18 | 24 |
SELECT id.guid, sm.obsoleted_by |
... | ... | |
30 | 36 |
ON q.obsoleted_by = newer.guid |
31 | 37 |
) |
32 | 38 |
SELECT guid, obsoleted_by |
33 |
INTO current_documents |
|
34 | 39 |
FROM q |
35 | 40 |
WHERE obsoleted_by is null |
36 | 41 |
ORDER BY guid; |
Also available in: Unified diff
merge recent upgrade changes from 2.4 branch