Project

General

Profile

1
/*
2
 * reviseformetacat13_postgres.sql -- Add three columns to xml_access tables
3
 * and create a new table in Production Metacat
4
 *
5
 *      Created: 07/14/2002
6
 *       Author: Jing Tao
7
 * Organization: National Center for Ecological Analysis and Synthesis
8
 *    Copyright: 2000 Regents of the University of California and the
9
 *               National Center for Ecological Analysis and Synthesis
10
 *  For Details: http://www.nceas.ucsb.edu/
11
 *    File Info: '$Id: reviseformetacat13_postgres.sql 1611 2003-04-24 22:18:30Z tao $'
12
 *
13
 */
14

    
15

    
16
/*
17
 * Add tow columns - datareplicate and hub to xml_access
18
 */
19
ALTER TABLE xml_access ADD subtreeid VARCHAR(32);
20
ALTER TABLE xml_access ADD startnodeid INT8;
21
ALTER TABLE xml_access ADD endnodeid INT8;
22

    
23
/*
24
 * accesssubtree -- table to store access subtree info
25
 */
26
CREATE TABLE xml_accesssubtree (
27
        docid           VARCHAR(250),   -- the document id #
28
  rev           INT8 default 1, --the revision number of the docume
29
  controllevel VARCHAR(50), -- the level it control -- document or subtree
30
  subtreeid VARCHAR(250), -- the subtree id
31
        startnodeid     INT8,   -- the start node id of access subtree
32
  endnodeid INT8 -- the end node if of access subtree
33
);
34

    
35
/*
36
 * We need to drop constraint(subject, relationship, object) and create new
37
 * new (docid, subject, relationship, object). Unfortunately, progres doesn't
38
 * remove the constrain directly and we should create a new one and copy the
39
 * old data to new one, then rename them.
40
 */
41
ALTER TABLE xml_relation RENAME TO old_xml_relation;
42
DROP INDEX xml_relation_pkey;
43
/*DROP SEQUENCE xml_relation_id_seq;
44
*CREATE SEQUENCE xml_relation_id_seq;
45
*/
46
CREATE TABLE xml_relation (
47
        relationid INT8 default nextval('xml_relation_id_seq') PRIMARY KEY,
48
                                             -- unique id
49
        docid VARCHAR(250) ,         -- the docid of the package file
50
                                             -- that this relation came from
51
        packagetype VARCHAR(250),          -- the type of the package
52
        subject VARCHAR(512) NOT NULL, -- the subject of the relation
53
        subdoctype VARCHAR(128),                -- the doctype of the subject
54
        relationship VARCHAR(128)  NOT NULL,-- the relationship type
55
        object VARCHAR(512) NOT NULL, -- the object of the relation
56
        objdoctype VARCHAR(128),          -- the doctype of the object
57
        CONSTRAINT xml_relation_uk1 UNIQUE (docid, subject, relationship, object),
58
        CONSTRAINT xml_relation_docid_fk1
59
                FOREIGN KEY (docid) REFERENCES xml_documents
60
);
61
INSERT INTO xml_relation SELECT * FROM old_xml_relation;
62

    
63

    
(6-6/18)