Project

General

Profile

« Previous | Next » 

Revision 1608

Added by Jing Tao over 21 years ago

It is as same as version 7.1.

View differences:

src/reviseformetacat13_postgres_7_2.sql
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$'
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
DROP SEQUENCE xml_relation_id_seq;
42
CREATE SEQUENCE xml_relation_id_seq;
43
CREATE TABLE new_xml_relation (
44
        relationid INT8 default nextval('xml_relation_id_seq') PRIMARY KEY,
45
                                             -- unique id
46
        docid VARCHAR(250) ,         -- the docid of the package file
47
                                             -- that this relation came from
48
        packagetype VARCHAR(250),          -- the type of the package
49
        subject VARCHAR(512) NOT NULL, -- the subject of the relation
50
        subdoctype VARCHAR(128),                -- the doctype of the subject
51
        relationship VARCHAR(128)  NOT NULL,-- the relationship type
52
        object VARCHAR(512) NOT NULL, -- the object of the relation
53
        objdoctype VARCHAR(128),          -- the doctype of the object
54
        CONSTRAINT xml_relation_uk UNIQUE (docid, subject, relationship, object),
55
        CONSTRAINT xml_relation_docid_fk
56
                FOREIGN KEY (docid) REFERENCES xml_documents
57
) AS SELECT relationid, docid, packagetype, subject, subdoctype, relationship, object, objdoctype FROM xml_relaion;
58

  
59
ALTER TABLE xml_relation RENAME TO old_xml_relation;
60

  
61
ALTER TABLE new_xml_relation RENAME TO xml_relation;
62

  
63

  
64

  
65 0

  

Also available in: Unified diff