Project

General

Profile

« Previous | Next » 

Revision 1611

Added by Jing Tao over 21 years ago

Add the code to drop the unique constrain (subject, relationship, object) and add(docid, subject, relationship, object)

View differences:

src/reviseformetacat13_postgres.sql
32 32
  endnodeid INT8 -- the end node if of access subtree
33 33
);
34 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

  

Also available in: Unified diff