Project

General

Profile

« Previous | Next » 

Revision 4104

Added by daigle almost 16 years ago

replace <script>.sql files with <script>-oracle.sql files since the base files are implicitly oracle scripts

View differences:

src/upgrade-db-to-1.3.sql
1
/*
2
 * xmlreplicationtables.sql -- Add three columns to xml_access tables
3
 * 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 three columns to xml_access
18
 */
19
ALTER TABLE xml_access ADD (subtreeid VARCHAR2(32), startnodeid NUMBER(20), endnodeid NUMBER(20) );
20

  
21
/*
22
 * accesssubtree -- table to store access subtree info
23
 */
24
CREATE TABLE xml_accesssubtree (
25
	docid		VARCHAR2(250),	-- the document id #
26
  rev 		NUMBER(10) DEFAULT 1, --the revision number of the docume
27
  controllevel VARCHAR2(50), -- the level it control -- document or subtree
28
  subtreeid VARCHAR2(250), -- the subtree id 
29
	startnodeid	NUMBER(20),	-- the start node id of access subtree
30
  endnodeid NUMBER(20), -- the end node if of access subtree
31
  CONSTRAINT xml_accesssubtree_docid_fk 
32
		FOREIGN KEY (docid) REFERENCES xml_documents
33
);
34

  
35
/*
36
 * Drop the constrain in xml_relation table for (subject, relationship, object)
37
 * Add the new constrain in xml_relation table for (docid, subject, relationship, object)
38
 */
39
ALTER TABLE xml_relation DROP CONSTRAINT xml_relation_uk;
40
ALTER TABLE xml_relation ADD  CONSTRAINT xml_relation_uk UNIQUE (docid, subject, relationship, object); 
41 0

  
src/upgrade-db-to-1.5.sql
1
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2004 Regents of the University of California and the
4
 *             National Center for Ecological Analysis and Synthesis
5
 *
6
 *   '$Author$'
7
 *     '$Date$'
8
 * '$Revision$'
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 */
24
 
25

  
26

  
27
/*
28
 * Update the XML_CATALOG table. In Metacat 1.4.0, the system_id in xml_catalog
29
 * pointed to knb metacat no matter where you install it. We need change it
30
 * to local schema or dtd file.
31
 */
32
UPDATE xml_catalog 
33
   SET system_id = '/dtd/eml-access-@eml-version@.dtd'
34
   WHERE public_id = '-//ecoinformatics.org//eml-access-@eml-version@//EN';
35
UPDATE xml_catalog 
36
   SET system_id = '/dtd/eml-attribute-@eml-version@.dtd'
37
   WHERE public_id = '-//ecoinformatics.org//eml-attribute-@eml-version@//EN';
38
UPDATE xml_catalog 
39
   SET system_id = '/dtd/eml-constraint-@eml-version@.dtd'
40
   WHERE public_id = '-//ecoinformatics.org//eml-constraint-@eml-version@//EN';
41
UPDATE xml_catalog 
42
   SET system_id = '/dtd/eml-coverage-@eml-version@.dtd'
43
   WHERE public_id = '-//ecoinformatics.org//eml-coverage-@eml-version@//EN';
44
UPDATE xml_catalog 
45
   SET system_id = '/dtd/eml-coverage-@eml-version@.dtd'
46
   WHERE public_id = '-//ecoinformatics.org//eml-coverage-@eml-version@//EN';
47
UPDATE xml_catalog 
48
   SET system_id = '/dtd/eml-dataset-@eml-version@.dtd'
49
   WHERE public_id = '-//ecoinformatics.org//eml-dataset-@eml-version@//EN';
50
UPDATE xml_catalog 
51
   SET system_id = '/dtd/eml-entity-@eml-version@.dtd'
52
   WHERE public_id = '-//ecoinformatics.org//eml-entity-@eml-version@//EN';
53
UPDATE xml_catalog 
54
   SET system_id = '/dtd/eml-literature-@eml-version@.dtd'
55
   WHERE public_id = '-//ecoinformatics.org//eml-literature-@eml-version@//EN';
56
UPDATE xml_catalog 
57
   SET system_id = '/dtd/eml-physical-@eml-version@.dtd'
58
   WHERE public_id = '-//ecoinformatics.org//eml-physical-@eml-version@//EN';
59
UPDATE xml_catalog 
60
   SET system_id = '/dtd/eml-project-@eml-version@.dtd'
61
   WHERE public_id = '-//ecoinformatics.org//eml-project-@eml-version@//EN';
62
UPDATE xml_catalog 
63
   SET system_id = '/dtd/eml-protocol-@eml-version@.dtd'
64
   WHERE public_id = '-//ecoinformatics.org//eml-protocol-@eml-version@//EN';
65
UPDATE xml_catalog 
66
   SET system_id = '/dtd/eml-software-@eml-version@.dtd'
67
   WHERE public_id = '-//ecoinformatics.org//eml-software-@eml-version@//EN';
68
UPDATE xml_catalog
69
  SET system_id = '/schema/eml-2.0.0/eml.xsd'
70
  WHERE public_id = '@eml2_0_0namespace@';
71
UPDATE xml_catalog
72
  SET system_id = '/schema/eml-2.0.1/eml.xsd'
73
  WHERE public_id = '@eml2_0_1namespace@';
74
UPDATE xml_catalog 
75
   SET system_id = '/schema/eml-2.0.0/stmml.xsd'
76
   WHERE public_id = '@stmmlnamespace@';
77

  
78
   
79
/*
80
 * In Metacat 1.4.0, if user insert a eml201 document and has record in xml_relation
81
 * table. The package type in xml_relation table will be eml200 rather than eml201.
82
 * The bug was fixed and we need a sql command to fix exsited records
83
 */
84
 UPDATE xml_relation SET packagetype='eml://ecoinformatics.org/eml-2.0.1' 
85
    WHERE docid IN (SELECT docid from xml_documents WHERE doctype LIKE 'eml://ecoinformatics.org/eml-2.0.1');
86

  
87
      
88
/*
89
 * Returnfields -- table to store combinations of returnfields requested
90
 *                 and the number of times this table is accessed
91
 */
92
CREATE TABLE xml_returnfield (
93
        returnfield_id     NUMBER(20),     -- the id for this returnfield entry
94
        returnfield_string VARCHAR2(2000), -- the returnfield string
95
        usage_count        NUMBER(20),     -- the number of times this string
96
                                           -- has been requested
97
        CONSTRAINT xml_returnfield_pk PRIMARY KEY (returnfield_id)
98
);
99
CREATE INDEX xml_returnfield_idx1 ON xml_returnfield(returnfield_string);
100
                                                                                 
101
CREATE SEQUENCE xml_returnfield_id_seq;
102
                                                                                 
103

  
104
/*
105
 * Queryresults -- table to store queryresults for a given docid
106
 * and returnfield_id
107
 */
108
CREATE TABLE xml_queryresult(
109
  queryresult_id       NUMBER(20),     -- id for this entry
110
  returnfield_id       NUMBER(20),     -- id for the returnfield corresponding to this entry
111
  docid                VARCHAR2(250),  -- docid of the document
112
  queryresult_string   VARCHAR2(4000), -- resultant text generated for this docid and given
113
                                       -- returnfield
114
  CONSTRAINT xml_queryresult_pk PRIMARY KEY (queryresult_id),
115
  CONSTRAINT xml_queryresult_searchid_fk
116
               FOREIGN KEY (returnfield_id) REFERENCES xml_returnfield
117
);
118
                                                                                 
119
CREATE INDEX xml_queryresult_idx1 ON xml_queryresult (returnfield_id, docid);
120
                                                                                 
121
CREATE SEQUENCE xml_queryresult_id_seq;
122

  
123 0

  
src/upgrade-db-to-1.7.sql
1
/*
2
 * New indexes to make queries avoid full table scans.
3
 */
4
CREATE INDEX xml_documents_idx2 ON xml_documents (lower(user_owner));
5
CREATE INDEX xml_access_idx1 ON xml_access (lower(principal_name));
6
CREATE INDEX xml_access_idx2 ON xml_access (permission);
7
CREATE INDEX xml_access_idx3 ON xml_access (perm_type);
8
CREATE INDEX xml_access_idx4 ON xml_access (perm_order);
9
CREATE INDEX xml_access_idx5 ON xml_access (subtreeid);
10
CREATE INDEX xml_path_index_idx4 ON xml_path_index (upper(nodedata));
11

  
12
/** done */
13 0

  
src/upgrade-db-to-1.9.sql
1
/*
2
 * db_version -- table to store the version history of this database
3
 */
4
CREATE TABLE db_version (
5
  db_version_id   NUMBER(20),       -- the identifier for the version
6
  version         VARCHAR(250),     -- the version number
7
  status          NUMBER(20),       -- status of the version
8
  date_created    DATE,             -- the datetime on which the version was created
9
  CONSTRAINT db_version_pk PRIMARY KEY (db_version_id)
10
);
11

  
12
CREATE SEQUENCE db_version_id_seq;
13
CREATE TRIGGER db_version_before_insert
14
BEFORE INSERT ON db_version FOR EACH ROW
15
BEGIN
16
  SELECT db_version_id_seq.nextval
17
    INTO :new.db_version_id
18
    FROM dual;
19
END;
20
/
21

  
22
INSERT INTO db_version (version, status, date_created) 
23
  VALUES ('1.8.0', 1, CURRENT_DATE);
24 0

  
src/loaddtdschema.sql
1
DELETE FROM xml_catalog 
2
      WHERE entry_type LIKE 'DTD'
3
        AND public_id LIKE '%@eml-version@%';
4
DELETE FROM xml_catalog 
5
      WHERE entry_type LIKE 'Schema'
6
        AND system_id LIKE '%eml%';
7
INSERT INTO xml_catalog (entry_type, public_id, system_id)
8
  VALUES ('DTD', '-//ecoinformatics.org//eml-access-@eml-version@//EN',
9
         '/dtd/eml-access-@eml-version@.dtd');
10
INSERT INTO xml_catalog (entry_type, public_id, system_id)
11
  VALUES ('DTD', '-//ecoinformatics.org//eml-attribute-@eml-version@//EN',
12
          '/dtd/eml-attribute-@eml-version@.dtd');
13
INSERT INTO xml_catalog (entry_type, public_id, system_id)
14
  VALUES ('DTD', '-//ecoinformatics.org//eml-constraint-@eml-version@//EN',
15
          '/dtd/eml-constraint-@eml-version@.dtd');
16
INSERT INTO xml_catalog (entry_type, public_id, system_id)
17
  VALUES ('DTD', '-//ecoinformatics.org//eml-coverage-@eml-version@//EN',
18
          '/dtd/eml-coverage-@eml-version@.dtd');
19
INSERT INTO xml_catalog (entry_type, public_id, system_id)
20
  VALUES ('DTD', '-//ecoinformatics.org//eml-dataset-@eml-version@//EN',
21
          '/dtd/eml-dataset-@eml-version@.dtd');
22
INSERT INTO xml_catalog (entry_type, public_id, system_id)
23
  VALUES ('DTD', '-//ecoinformatics.org//eml-entity-@eml-version@//EN',
24
          '/dtd/eml-entity-@eml-version@.dtd');
25
INSERT INTO xml_catalog (entry_type, public_id, system_id)
26
  VALUES ('DTD', '-//ecoinformatics.org//eml-literature-@eml-version@//EN',
27
          '/dtd/eml-literature-@eml-version@.dtd');
28
INSERT INTO xml_catalog (entry_type, public_id, system_id)
29
  VALUES ('DTD', '-//ecoinformatics.org//eml-physical-@eml-version@//EN',
30
          '/dtd/eml-physical-@eml-version@.dtd');
31
INSERT INTO xml_catalog (entry_type, public_id, system_id)
32
  VALUES ('DTD', '-//ecoinformatics.org//eml-project-@eml-version@//EN',
33
          '/dtd/eml-project-@eml-version@.dtd');
34
INSERT INTO xml_catalog (entry_type, public_id, system_id)
35
  VALUES ('DTD', '-//ecoinformatics.org//eml-protocol-@eml-version@//EN',
36
          '/dtd/eml-protocol-@eml-version@.dtd');
37
INSERT INTO xml_catalog (entry_type, public_id, system_id)
38
  VALUES ('DTD', '-//ecoinformatics.org//eml-software-@eml-version@//EN',
39
          '/dtd/eml-software-@eml-version@.dtd');
40
INSERT INTO xml_catalog (entry_type, public_id, system_id)
41
  VALUES ('Schema', '@eml2_0_1namespace@', '/schema/eml-2.0.1/eml.xsd');
42
INSERT INTO xml_catalog (entry_type, public_id, system_id)
43
  VALUES ('Schema', '@eml2_0_0namespace@', '/schema/eml-2.0.0/eml.xsd');
44
INSERT INTO xml_catalog (entry_type, public_id, system_id)
45
  VALUES ('Schema', '@stmmlnamespace@', '/schema/eml-2.0.1/stmml.xsd');
46
INSERT INTO xml_catalog (entry_type, public_id, system_id)
47
  VALUES ('Schema', 'metadata', '/schema/fgdc-std-001/fgdc-std-001-1998.xsd');
48

  
49
INSERT INTO db_version (version, status, date_created) 
50
  VALUES ('1.9.0',1,CURRENT_DATE);
51 0

  
src/upgrade-db-to-1.2.sql
1
/*
2
 * xmlreplicationtables.sql -- Add two columns to xml_replication tables 
3
 * 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_replication 
18
 */
19
ALTER TABLE xml_replication ADD ( datareplicate NUMBER(1), hub NUMBER(1) );
20

  
21 0

  
src/upgrade-db-to-1.4.sql
1
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2004 Regents of the University of California and the
4
 *             National Center for Ecological Analysis and Synthesis
5
 *
6
 *   '$Author$'
7
 *     '$Date$'
8
 * '$Revision$'
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 */
24
 
25
/*
26
 * Logging -- table to store metadata and data access log
27
 */
28
CREATE TABLE access_log (
29
  entryid       NUMBER(20),     -- the identifier for the log event
30
  ip_address    VARCHAR2(512),  -- the ip address inititiating the event
31
  principal     VARCHAR2(512),  -- the user initiiating the event
32
  docid         VARCHAR2(250),	-- the document id #
33
  event         VARCHAR2(512),  -- the code symbolizing the event type
34
  date_logged   DATE,           -- the datetime on which the event occurred
35
  CONSTRAINT access_log_pk PRIMARY KEY (entryid)
36
);  
37
 
38
CREATE SEQUENCE access_log_id_seq;
39
CREATE TRIGGER access_log_before_insert
40
BEFORE INSERT ON access_log FOR EACH ROW
41
BEGIN
42
  SELECT access_log_id_seq.nextval
43
    INTO :new.entryid
44
    FROM dual;
45
END;
46
/
47

  
48
/* 
49
 * harvest_site_schedule -- table to store harvest sites and schedule info
50
 */
51
CREATE TABLE harvest_site_schedule (
52
  site_schedule_id NUMBER,         -- unique id
53
  documentlisturl  VARCHAR2(255),  -- URL of the site harvest document list
54
  ldapdn           VARCHAR2(255),  -- LDAP distinguished name for site account
55
  datenextharvest  DATE,           -- scheduled date of next harvest
56
  datelastharvest  DATE,           -- recorded date of last harvest
57
  updatefrequency  NUMBER,         -- the harvest update frequency
58
  unit             VARCHAR2(50),   -- update unit -- days weeks or months
59
  contact_email    VARCHAR2(50),   -- email address of the site contact person
60
  ldappwd          VARCHAR2(20),   -- LDAP password for site account
61
  CONSTRAINT harvest_site_schedule_pk PRIMARY KEY (site_schedule_id)
62
);
63

  
64
/* 
65
 * harvest_log -- table to log entries for harvest operations
66
 */
67
CREATE TABLE harvest_log (
68
  harvest_log_id         NUMBER,         -- unique id
69
  harvest_date           DATE,           -- date of the current harvest
70
  status                 NUMBER,         -- non-zero indicates an error status
71
  message                VARCHAR2(1000), -- text message for this log entry
72
  harvest_operation_code VARCHAR2(30),   -- the type of harvest operation
73
  site_schedule_id       NUMBER,         -- site schedule id, or 0 if no site
74
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id)
75
);
76

  
77
/* 
78
 * harvest_detail_log -- table to log detailed info about documents that
79
 *                       generated errors during the harvest
80
 */
81
CREATE TABLE harvest_detail_log (
82
  detail_log_id          NUMBER,         -- unique id
83
  harvest_log_id         NUMBER,         -- ponter to the related log entry
84
  scope                  VARCHAR2(50),   -- document scope
85
  identifier             NUMBER,         -- document identifier
86
  revision               NUMBER,         -- document revision
87
  document_url           VARCHAR2(255),  -- document URL
88
  error_message          VARCHAR2(1000), -- text error message
89
  document_type          VARCHAR2(100),  -- document type
90
  CONSTRAINT harvest_detail_log_pk PRIMARY KEY (detail_log_id),
91
  CONSTRAINT harvest_detail_log_fk 
92
        FOREIGN KEY (harvest_log_id) REFERENCES harvest_log
93
);
94

  
95
/*
96
 * Modify the xml_index.path to the new larger size
97
 */
98
ALTER TABLE xml_index MODIFY (path VARCHAR2(1000));
99

  
100
/*
101
 * Update the XML_CATALOG table with new entries, and change old ones
102
 */
103
INSERT INTO xml_catalog (entry_type, public_id, system_id)
104
  VALUES ('Schema', '@eml2_0_1namespace@', '/schema/eml-2.0.1/eml.xsd');
105
UPDATE xml_catalog
106
  SET system_id = '/schema/eml-2.0.0/eml.xsd'
107
  WHERE public_id = '@eml2_0_0namespace@';
108
UPDATE xml_catalog
109
  SET system_id = '/schema/eml-2.0.0/stmml.xsd'
110
  WHERE public_id = '@stmmlnamespace@';
111 0

  
src/upgrade-db-to-1.8.sql
1
CREATE INDEX xml_index_idx2 ON xml_index (docid);
2
CREATE INDEX xml_nodes_idx4 ON xml_nodes (docid);
3
CREATE INDEX xml_documents_idx3 ON xml_documents (rootnodeid);
4
CREATE INDEX xml_index_idx3 ON xml_index (nodeid);
5 0

  
src/xmltables.sql
1
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2004 Regents of the University of California and the
4
 *             National Center for Ecological Analysis and Synthesis
5
 *
6
 *   '$Author$'
7
 *     '$Date$'
8
 * '$Revision$'
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 */
24

  
25
/*
26
 * Drop all of the objects in proper order
27
 */
28
set echo off
29

  
30
DROP SEQUENCE xml_nodes_id_seq;
31
DROP SEQUENCE xml_revisions_id_seq;
32
DROP SEQUENCE xml_catalog_id_seq;
33
DROP SEQUENCE xml_relation_id_seq;
34
DROP SEQUENCE xml_replication_id_seq;
35
DROP SEQUENCE identifier_id_seq;
36
DROP SEQUENCE access_log_id_seq;
37
DROP SEQUENCE xml_returnfield_id_seq;
38
DROP SEQUENCE xml_queryresult_id_seq;
39
DROP SEQUENCE xml_path_index_id_seq;
40
DROP SEQUENCE db_version_id_seq;
41

  
42
/* Drop triggers are not necessary */
43
DROP TRIGGER xml_nodes_before_insert;
44
DROP TRIGGER xml_revisions_before_insert;
45
DROP TRIGGER xml_catalog_before_insert;
46
DROP TRIGGER xml_relation_before_insert;
47
DROP TRIGGER xml_replication_before_insert;
48
DROP TRIGGER identifier_before_insert;
49
DROP TRIGGER access_log_before_insert;
50
DROP TRIGGER xml_returnfield_before_insert;
51
DROP TRIGGER xml_queryresult_before_insert;
52
DROP TRIGGER db_version_before_insert;
53

  
54

  
55
DROP TABLE xml_index;
56
DROP TABLE xml_access;
57
DROP TABLE xml_accesssubtree;
58
DROP TABLE xml_revisions;
59
DROP TABLE xml_relation;
60
DROP TABLE xml_documents CASCADE CONSTRAINTS;
61
DROP TABLE xml_nodes;
62
DROP TABLE xml_nodes_revisions;
63
DROP TABLE xml_replication;
64
DROP TABLE xml_catalog;
65
DROP TABLE identifier;
66
DROP TABLE access_log;
67
DROP TABLE harvest_site_schedule;
68
DROP TABLE harvest_detail_log;
69
DROP TABLE harvest_log;
70
DROP TABLE xml_queryresult;
71
DROP TABLE xml_returnfield;
72
DROP TABLE xml_path_index;
73
DROP TABLE db_version;
74

  
75
/*
76
 *Replication -- table to store servers that metacat is replicated to
77
 */
78
CREATE TABLE xml_replication (
79
  serverid      NUMBER(20),
80
  server        VARCHAR2(512),
81
  last_checked  DATE,
82
  replicate     NUMBER(1),
83
  datareplicate NUMBER(1),
84
  hub NUMBER(1),
85
  CONSTRAINT xml_replication_pk PRIMARY KEY (serverid)
86
);
87

  
88
CREATE SEQUENCE xml_replication_id_seq;
89
CREATE TRIGGER xml_replication_before_insert
90
BEFORE INSERT ON xml_replication FOR EACH ROW
91
BEGIN
92
  SELECT xml_replication_id_seq.nextval
93
    INTO :new.serverid
94
    FROM dual;
95
END;
96
/
97

  
98
INSERT INTO xml_replication (server, replicate, datareplicate, hub)
99
 VALUES ('localhost', '0', '0', '0');
100

  
101
/*
102
 * Nodes -- table to store XML Nodes (both elements and attributes)
103
 */
104
CREATE SEQUENCE xml_nodes_id_seq;
105
CREATE TABLE xml_nodes (
106
	nodeid		NUMBER(20),	-- the unique node id (pk)
107
	nodeindex	NUMBER(10),	-- order of nodes within parent
108
	nodetype	VARCHAR2(20),	-- type (DOCUMENT, COMMENT, PI,
109
					-- ELEMENT, ATTRIBUTE, TEXT)
110
	nodename	VARCHAR2(250),	-- the name of an element or attribute
111
	nodeprefix	VARCHAR2(50),	-- the namespace prefix of an element
112
                                        -- or attribute
113
	nodedata	VARCHAR2(4000), -- the data for this node (e.g.,
114
					-- for TEXT it is the content)
115
	parentnodeid	NUMBER(20),	-- index of the parent of this node
116
	rootnodeid	NUMBER(20),	-- index of the root node of this tree
117
	docid		VARCHAR2(250),	-- index to the document id
118
	date_created	DATE,
119
	date_updated	DATE,
120
	nodedatanumerical NUMBER,       -- the data for this node if
121
					-- it is a number
122
   CONSTRAINT xml_nodes_pk PRIMARY KEY (nodeid),
123
   CONSTRAINT xml_nodes_root_fk
124
		FOREIGN KEY (rootnodeid) REFERENCES xml_nodes,
125
   CONSTRAINT xml_nodes_parent_fk
126
		FOREIGN KEY (parentnodeid) REFERENCES xml_nodes
127
);
128
CREATE TRIGGER xml_nodes_before_insert
129
BEFORE INSERT ON xml_nodes FOR EACH ROW
130
BEGIN
131
  SELECT xml_nodes_id_seq.nextval
132
    INTO :new.nodeid
133
    FROM dual;
134
END;
135
/
136

  
137

  
138
/*
139
 * Indexes of rootnodeid, parentnodeid, and nodename in xml_nodes
140
 */
141
CREATE INDEX xml_nodes_idx1 ON xml_nodes (rootnodeid);
142
CREATE INDEX xml_nodes_idx2 ON xml_nodes (parentnodeid);
143
CREATE INDEX xml_nodes_idx3 ON xml_nodes (nodename);
144
CREATE INDEX xml_nodes_idx4 ON xml_nodes (docid);
145

  
146

  
147
/*
148
 * xml_nodes_revisions -- table to store nodes from xml_nodes which are of old revisions and deleted document
149
 */
150

  
151
CREATE TABLE xml_nodes_revisions (
152
        nodeid          NUMBER(20),     -- the unique node id (pk)
153
        nodeindex       NUMBER(10),     -- order of nodes within parent
154
        nodetype        VARCHAR2(20),   -- type (DOCUMENT, COMMENT, PI,
155
                                        -- ELEMENT, ATTRIBUTE, TEXT)
156
        nodename        VARCHAR2(250),  -- the name of an element or attribute
157
        nodeprefix      VARCHAR2(50),   -- the namespace prefix of an element
158
                                        -- or attribute
159
        nodedata        VARCHAR2(4000), -- the data for this node (e.g.,
160
                                        -- for TEXT it is the content)
161
        parentnodeid    NUMBER(20),     -- index of the parent of this node
162
        rootnodeid      NUMBER(20),     -- index of the root node of this tree
163
        docid           VARCHAR2(250),  -- index to the document id
164
        date_created    DATE,
165
        date_updated    DATE,
166
        nodedatanumerical NUMBER,       -- the data for this node if
167
                                        -- it is a number
168
   CONSTRAINT xml_nodes_revisions_pk PRIMARY KEY (nodeid),
169
   CONSTRAINT xml_nodes_revisions_root_fk
170
                FOREIGN KEY (rootnodeid) REFERENCES xml_nodes_revisions,
171
   CONSTRAINT xml_nodes_revisions_parent_fk
172
                FOREIGN KEY (parentnodeid) REFERENCES xml_nodes_revisions
173
);
174

  
175

  
176
/*
177
 * Indexes of rootnodeid, parentnodeid, and nodename in xml_nodes_revision
178
 */
179
CREATE INDEX xml_nodes_revisions_idx1 ON xml_nodes_revisions (rootnodeid);
180
CREATE INDEX xml_nodes_revisions_idx2 ON xml_nodes_revisions (parentnodeid);
181
CREATE INDEX xml_nodes_revisions_idx3 ON xml_nodes_revisions (nodename);
182

  
183
/*
184
 * XML Catalog -- table to store all external sources for XML documents
185
 */
186
CREATE TABLE xml_catalog (
187
	catalog_id	NUMBER(20),	-- the id for this catalog entry
188
	entry_type	VARCHAR2(500),	-- the type of this catalog entry
189
					-- (e.g., DTD, XSD, XSL)
190
	source_doctype	VARCHAR2(500),	-- the source public_id for transforms
191
	target_doctype	VARCHAR2(500),	-- the target public_id for transforms
192
	public_id	VARCHAR2(500),	-- the unique id for this type
193
	system_id	VARCHAR2(1000),	-- the local location of the object
194
   CONSTRAINT xml_catalog_pk PRIMARY KEY (catalog_id),
195
   CONSTRAINT xml_catalog_uk UNIQUE
196
		(entry_type, source_doctype, target_doctype, public_id)
197
);
198

  
199
CREATE SEQUENCE xml_catalog_id_seq;
200

  
201
CREATE TRIGGER xml_catalog_before_insert
202
BEFORE INSERT ON xml_catalog FOR EACH ROW
203
BEGIN
204
  SELECT xml_catalog_id_seq.nextval
205
    INTO :new.catalog_id
206
    FROM dual;
207
END;
208
/
209

  
210
/*
211
 * Documents -- table to store XML documents
212
 */
213
CREATE TABLE xml_documents (
214
	docid		VARCHAR2(250),	-- the document id #
215
	rootnodeid	NUMBER(20),	-- reference to root node of the DOM
216
	docname		VARCHAR2(100),	-- usually the root element name
217
	doctype		VARCHAR2(100),	-- public id indicating document type
218
	user_owner	VARCHAR2(100),	-- the user owned the document
219
	user_updated	VARCHAR2(100),	-- the user updated the document
220
	server_location NUMBER(20),	-- the server on which this document
221
                                        -- originates
222
	rev 		NUMBER(10) DEFAULT 1,--the revision number of the docume
223
	date_created	DATE,
224
	date_updated	DATE,
225
	public_access	NUMBER(1),	-- flag for public access
226
        catalog_id      NUMBER(20),	-- reference to xml_catalog
227
   CONSTRAINT xml_documents_pk PRIMARY KEY (docid),
228
   CONSTRAINT xml_documents_rep_fk
229
    		FOREIGN KEY (server_location) REFERENCES xml_replication,
230
   CONSTRAINT xml_documents_root_fk
231
		FOREIGN KEY (rootnodeid) REFERENCES xml_nodes,
232
   CONSTRAINT xml_documents_catalog_fk
233
		FOREIGN KEY (catalog_id) REFERENCES xml_catalog
234
);
235

  
236
/*
237
 * Index of <docid,doctype> in xml_document
238
 */
239
CREATE INDEX xml_documents_idx1 ON xml_documents (docid, doctype);
240
CREATE INDEX xml_documents_idx3 ON xml_documents (rootnodeid);
241

  
242
/*
243
 * Revised Documents -- table to store XML documents saved after an UPDATE
244
 *                    or DELETE
245
 */
246
CREATE TABLE xml_revisions (
247
	revisionid	NUMBER(20),	-- the revision number we are saving
248
	docid		VARCHAR2(250),	-- the document id #
249
	rootnodeid	NUMBER(20),	-- reference to root node of the DOM
250
	docname		VARCHAR2(100),	-- usually the root element name
251
	doctype		VARCHAR2(100),	-- public id indicating document type
252
	user_owner	VARCHAR2(100),
253
	user_updated	VARCHAR2(100),
254
	server_location NUMBER(20),
255
	rev		NUMBER(10),
256
	date_created	DATE,
257
	date_updated	DATE,
258
	public_access	NUMBER(1),	-- flag for public access
259
        catalog_id      NUMBER(20),	-- reference to xml_catalog
260
   CONSTRAINT xml_revisions_pk PRIMARY KEY (revisionid),
261
   CONSTRAINT xml_revisions_rep_fk
262
		FOREIGN KEY (server_location) REFERENCES xml_replication,
263
   CONSTRAINT xml_revisions_root_fk
264
		FOREIGN KEY (rootnodeid) REFERENCES xml_nodes_revisions,
265
   CONSTRAINT xml_revisions_catalog_fk
266
		FOREIGN KEY (catalog_id) REFERENCES xml_catalog
267
);
268

  
269
CREATE SEQUENCE xml_revisions_id_seq;
270

  
271
CREATE TRIGGER xml_revisions_before_insert
272
BEFORE INSERT ON xml_revisions FOR EACH ROW
273
BEGIN
274
  SELECT xml_revisions_id_seq.nextval
275
    INTO :new.revisionid
276
    FROM dual;
277
END;
278
/
279

  
280
/*
281
 * ACL -- table to store ACL for XML documents by principals
282
 */
283
CREATE TABLE xml_access (
284
	docid		VARCHAR2(250),	-- the document id #
285
	accessfileid	VARCHAR2(250),	-- the document id # for the access file
286
	principal_name	VARCHAR2(100),	-- name of user, group, etc.
287
	permission	NUMBER(1),	-- "read", "write", "all"
288
	perm_type	VARCHAR2(32),	-- "allowed" or "denied"
289
	perm_order	VARCHAR2(32),	-- "allow first" or "deny first"
290
	begin_time	DATE,		-- the time that permission begins
291
	end_time	DATE,		-- the time that permission ends
292
	ticket_count	NUMBER(5),	-- ticket counter for that permission
293
  subtreeid VARCHAR2(32), -- sub tree id
294
  startnodeid NUMBER(20), -- start node for sub tree
295
  endnodeid NUMBER(20),    -- end node for sub tree
296
   CONSTRAINT xml_access_ck CHECK (begin_time < end_time),
297
   CONSTRAINT xml_access_accessfileid_fk
298
		FOREIGN KEY (accessfileid) REFERENCES xml_documents
299
);
300

  
301

  
302

  
303
/*
304
 * Index of Nodes -- table to store precomputed paths through tree for
305
 * quick searching in structured searches
306
 */
307
CREATE TABLE xml_index (
308
	nodeid		NUMBER(20),	-- the unique node id
309
	path		VARCHAR2(1000),	-- precomputed path through tree
310
	docid		VARCHAR2(250),	-- index to the document id
311
	doctype		VARCHAR2(100),	-- public id indicating document type
312
        parentnodeid    NUMBER(20),     -- id of the parent of the node
313
					-- represented by this row
314
   CONSTRAINT xml_index_pk PRIMARY KEY (nodeid,path),
315
   CONSTRAINT xml_index_nodeid_fk FOREIGN KEY (nodeid) REFERENCES xml_nodes,
316
   CONSTRAINT xml_index_docid_fk
317
		FOREIGN KEY (docid) REFERENCES xml_documents
318
);
319

  
320
/*
321
 * Index of the paths in xml_index
322
 */
323
CREATE INDEX xml_index_idx1 ON xml_index (path);
324
CREATE INDEX xml_index_idx2 ON xml_index (docid);
325
CREATE INDEX xml_index_idx3 ON xml_index (nodeid);
326

  
327

  
328
/*
329
 * Index of Paths - table to store nodes with paths specified by userst in metacat.properties
330
 */
331
CREATE TABLE xml_path_index (
332
        nodeid          NUMBER(20),     -- the unique node id
333
        docid           VARCHAR2(250),  -- index to the document id
334
        path            VARCHAR2(1000), -- precomputed path through tree
335
	    nodedata        VARCHAR2(4000), -- the data for this node e.g.,
336
        nodedatanumerical NUMBER(20),   -- the data for this node if
337
        parentnodeid    NUMBER(20),     -- index of the parent of this node
338
        CONSTRAINT xml_path_index_pk PRIMARY KEY (nodeid),
339
        CONSTRAINT xml_path_index_docid_fk FOREIGN KEY (docid) REFERENCES xml_documents
340
 );                                                                                        
341

  
342

  
343
/*
344
 * create sequence an trigger
345
 */
346
CREATE SEQUENCE xml_path_index_id_seq;                                                                                                                                                             
347
CREATE TRIGGER xml_path_index_before_insert
348
BEFORE INSERT ON xml_path_index FOR EACH ROW
349
BEGIN
350
  SELECT xml_path_index_id_seq.nextval
351
    INTO :new.nodeid
352
    FROM dual;
353
END;
354
/
355

  
356

  
357
/*
358
 * Index of the path, nodedata, nodedatanumerical in xml_path_index
359
 */
360
CREATE INDEX xml_path_index_idx1 ON xml_path_index (path);
361
CREATE INDEX xml_path_index_idx2 ON xml_path_index (nodedata);
362
CREATE INDEX xml_path_index_idx3 ON xml_path_index (nodedatanumerical);
363

  
364

  
365

  
366
CREATE TABLE xml_relation (
367
	relationid    NUMBER(20) PRIMARY KEY, -- unique id
368
	docid         VARCHAR2(250),          -- the docid of the package file
369
	                                      -- that this relation came from
370
        packagetype   VARCHAR2(250),          -- the type of the package
371
	subject       VARCHAR2(512) NOT NULL, -- the subject of the relation
372
	subdoctype    VARCHAR2(128),          -- the doctype of the subject
373
	relationship  VARCHAR2(128)  NOT NULL,-- the relationship type
374
	object        VARCHAR2(512) NOT NULL, -- the object of the relation
375
	objdoctype    VARCHAR2(128),          -- the doctype of the object
376
	CONSTRAINT xml_relation_uk UNIQUE (docid, subject, relationship, object),
377
	CONSTRAINT xml_relation_docid_fk
378
		FOREIGN KEY (docid) REFERENCES xml_documents
379
  );
380

  
381
CREATE SEQUENCE xml_relation_id_seq;
382

  
383
CREATE TRIGGER xml_relation_before_insert
384
BEFORE INSERT ON xml_relation FOR EACH ROW
385
BEGIN
386
  SELECT xml_relation_id_seq.nextval
387
    INTO :new.relationid
388
    FROM dual;
389
END;
390
/
391

  
392
/*
393
 * Table used to store all document identifiers in metacat.  Each identifier
394
 * consists of 4 subparts, an authority, namespace, object, and revision as
395
 * defined in the LSID specification.
396
 */
397
CREATE SEQUENCE identifier_id_seq;
398
CREATE TABLE identifier (
399
   id        NUMBER(20) PRIMARY KEY, -- primary key
400
   authority VARCHAR2(255),  -- the authority issuing the identifier
401
   namespace VARCHAR2(255),  -- the namespace qualifying the identifier
402
   object    VARCHAR2(255),  -- the local part of the identifier for a particular object
403
   revision  VARCHAR2(255)   -- the revision part of the identifier
404
);
405
CREATE TRIGGER identifier_before_insert
406
BEFORE INSERT ON identifier FOR EACH ROW
407
BEGIN
408
  SELECT identifier_id_seq.nextval
409
    INTO :new.id
410
    FROM dual;
411
END;
412
/
413

  
414
/*
415
 * accesssubtree -- table to store access subtree info
416
 */
417
CREATE TABLE xml_accesssubtree (
418
	docid		VARCHAR2(250),	-- the document id #
419
  rev 		NUMBER(10) DEFAULT 1, --the revision number of the docume
420
  controllevel VARCHAR2(50), -- the level it control -- document or subtree
421
  subtreeid VARCHAR2(250), -- the subtree id
422
	startnodeid	NUMBER(20),	-- the start node id of access subtree
423
  endnodeid NUMBER(20), -- the end node if of access subtree
424
  CONSTRAINT xml_accesssubtree_docid_fk
425
		FOREIGN KEY (docid) REFERENCES xml_documents
426
);
427

  
428
/*
429
 * Returnfields -- table to store combinations of returnfields requested
430
 *		   and the number of times this table is accessed
431
 */
432
CREATE TABLE xml_returnfield (
433
        returnfield_id     NUMBER(20),     -- the id for this returnfield entry
434
        returnfield_string VARCHAR2(2000), -- the returnfield string
435
        usage_count        NUMBER(20),     -- the number of times this string
436
                                           -- has been requested
437
        CONSTRAINT xml_returnfield_pk PRIMARY KEY (returnfield_id)
438
);
439
CREATE INDEX xml_returnfield_idx1 ON xml_returnfield(returnfield_string);
440

  
441
CREATE SEQUENCE xml_returnfield_id_seq;
442

  
443
CREATE TRIGGER xml_returnfield_before_insert
444
BEFORE INSERT ON xml_returnfield FOR EACH ROW
445
BEGIN
446
  SELECT xml_returnfield_id_seq.nextval
447
    INTO :new.returnfield_id
448
    FROM dual;
449
END;
450
/
451

  
452
/*
453
 * Queryresults -- table to store queryresults for a given docid
454
 * and returnfield_id
455
 */
456
CREATE TABLE xml_queryresult(
457
  queryresult_id       NUMBER(20),     -- id for this entry
458
  returnfield_id       NUMBER(20),     -- id for the returnfield corresponding to this entry
459
  docid                VARCHAR2(250),  -- docid of the document
460
  queryresult_string   VARCHAR2(4000), -- resultant text generated for this docid and given
461
  				       -- returnfield
462
  CONSTRAINT xml_queryresult_pk PRIMARY KEY (queryresult_id),
463
  CONSTRAINT xml_queryresult_searchid_fk
464
               FOREIGN KEY (returnfield_id) REFERENCES xml_returnfield
465
);
466

  
467
CREATE INDEX xml_queryresult_idx1 ON xml_queryresult (returnfield_id, docid);
468

  
469
CREATE SEQUENCE xml_queryresult_id_seq;
470

  
471
CREATE TRIGGER xml_queryresult_before_insert
472
BEFORE INSERT ON xml_queryresult FOR EACH ROW
473
BEGIN
474
 SELECT xml_queryresult_id_seq.nextval
475
   INTO :new.queryresult_id
476
   FROM dual;
477
END;
478
/
479

  
480

  
481

  
482

  
483
/*
484
 * Logging -- table to store metadata and data access log
485
 */
486
CREATE TABLE access_log (
487
  entryid       NUMBER(20),     -- the identifier for the log event
488
  ip_address    VARCHAR2(512),  -- the ip address inititiating the event
489
  principal     VARCHAR2(512),  -- the user initiiating the event
490
  docid         VARCHAR2(250),	-- the document id #
491
  event         VARCHAR2(512),  -- the code symbolizing the event type
492
  date_logged   DATE,           -- the datetime on which the event occurred
493
  CONSTRAINT access_log_pk PRIMARY KEY (entryid)
494
);
495

  
496
CREATE SEQUENCE access_log_id_seq;
497
CREATE TRIGGER access_log_before_insert
498
BEFORE INSERT ON access_log FOR EACH ROW
499
BEGIN
500
  SELECT access_log_id_seq.nextval
501
    INTO :new.entryid
502
    FROM dual;
503
END;
504
/
505

  
506
/*
507
 * harvest_site_schedule -- table to store harvest sites and schedule info
508
 */
509
CREATE TABLE harvest_site_schedule (
510
  site_schedule_id NUMBER,         -- unique id
511
  documentlisturl  VARCHAR2(255),  -- URL of the site harvest document list
512
  ldapdn           VARCHAR2(255),  -- LDAP distinguished name for site account
513
  datenextharvest  DATE,           -- scheduled date of next harvest
514
  datelastharvest  DATE,           -- recorded date of last harvest
515
  updatefrequency  NUMBER,         -- the harvest update frequency
516
  unit             VARCHAR2(50),   -- update unit -- days weeks or months
517
  contact_email    VARCHAR2(50),   -- email address of the site contact person
518
  ldappwd          VARCHAR2(20),   -- LDAP password for site account
519
  CONSTRAINT harvest_site_schedule_pk PRIMARY KEY (site_schedule_id)
520
);
521

  
522
/*
523
 * harvest_log -- table to log entries for harvest operations
524
 */
525
CREATE TABLE harvest_log (
526
  harvest_log_id         NUMBER,         -- unique id
527
  harvest_date           DATE,           -- date of the current harvest
528
  status                 NUMBER,         -- non-zero indicates an error status
529
  message                VARCHAR2(1000), -- text message for this log entry
530
  harvest_operation_code VARCHAR2(30),   -- the type of harvest operation
531
  site_schedule_id       NUMBER,         -- site schedule id, or 0 if no site
532
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id)
533
);
534

  
535
/*
536
 * harvest_detail_log -- table to log detailed info about documents that
537
 *                       generated errors during the harvest
538
 */
539
CREATE TABLE harvest_detail_log (
540
  detail_log_id          NUMBER,         -- unique id
541
  harvest_log_id         NUMBER,         -- ponter to the related log entry
542
  scope                  VARCHAR2(50),   -- document scope
543
  identifier             NUMBER,         -- document identifier
544
  revision               NUMBER,         -- document revision
545
  document_url           VARCHAR2(255),  -- document URL
546
  error_message          VARCHAR2(1000), -- text error message
547
  document_type          VARCHAR2(100),  -- document type
548
  CONSTRAINT harvest_detail_log_pk PRIMARY KEY (detail_log_id),
549
  CONSTRAINT harvest_detail_log_fk
550
        FOREIGN KEY (harvest_log_id) REFERENCES harvest_log
551
);
552

  
553
/*
554
 * db_version -- table to store the version history of this database
555
 */
556
CREATE TABLE db_version (
557
  db_version_id   NUMBER(20),       -- the identifier for the version
558
  version         VARCHAR(250),     -- the version number
559
  status          NUMBER(20),       -- status of the version
560
  date_created    DATE,             -- the datetime on which the version was created
561
  CONSTRAINT db_version_pk PRIMARY KEY (db_version_id)
562
);
563

  
564
CREATE SEQUENCE db_version_id_seq;
565
CREATE TRIGGER db_version_before_insert
566
BEFORE INSERT ON db_version FOR EACH ROW
567
BEGIN
568
  SELECT db_version_id_seq.nextval
569
    INTO :new.db_version_id
570
    FROM dual;
571
END;
572
/
573

  
574 0

  
src/upgrade-db-to-1.2-oracle.sql
1
/*
2
 * upgrade-db-to-1.2-oracle.sql -- Add two columns to xml_replication tables 
3
 * 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_replication 
18
 */
19
ALTER TABLE xml_replication ADD ( datareplicate NUMBER(1), hub NUMBER(1) );
20

  
0 21

  
src/upgrade-db-to-1.4-oracle.sql
1
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2004 Regents of the University of California and the
4
 *             National Center for Ecological Analysis and Synthesis
5
 *
6
 *   '$Author$'
7
 *     '$Date$'
8
 * '$Revision$'
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 */
24
 
25
/*
26
 * Logging -- table to store metadata and data access log
27
 */
28
CREATE TABLE access_log (
29
  entryid       NUMBER(20),     -- the identifier for the log event
30
  ip_address    VARCHAR2(512),  -- the ip address inititiating the event
31
  principal     VARCHAR2(512),  -- the user initiiating the event
32
  docid         VARCHAR2(250),	-- the document id #
33
  event         VARCHAR2(512),  -- the code symbolizing the event type
34
  date_logged   DATE,           -- the datetime on which the event occurred
35
  CONSTRAINT access_log_pk PRIMARY KEY (entryid)
36
);  
37
 
38
CREATE SEQUENCE access_log_id_seq;
39
CREATE TRIGGER access_log_before_insert
40
BEFORE INSERT ON access_log FOR EACH ROW
41
BEGIN
42
  SELECT access_log_id_seq.nextval
43
    INTO :new.entryid
44
    FROM dual;
45
END;
46
/
47

  
48
/* 
49
 * harvest_site_schedule -- table to store harvest sites and schedule info
50
 */
51
CREATE TABLE harvest_site_schedule (
52
  site_schedule_id NUMBER,         -- unique id
53
  documentlisturl  VARCHAR2(255),  -- URL of the site harvest document list
54
  ldapdn           VARCHAR2(255),  -- LDAP distinguished name for site account
55
  datenextharvest  DATE,           -- scheduled date of next harvest
56
  datelastharvest  DATE,           -- recorded date of last harvest
57
  updatefrequency  NUMBER,         -- the harvest update frequency
58
  unit             VARCHAR2(50),   -- update unit -- days weeks or months
59
  contact_email    VARCHAR2(50),   -- email address of the site contact person
60
  ldappwd          VARCHAR2(20),   -- LDAP password for site account
61
  CONSTRAINT harvest_site_schedule_pk PRIMARY KEY (site_schedule_id)
62
);
63

  
64
/* 
65
 * harvest_log -- table to log entries for harvest operations
66
 */
67
CREATE TABLE harvest_log (
68
  harvest_log_id         NUMBER,         -- unique id
69
  harvest_date           DATE,           -- date of the current harvest
70
  status                 NUMBER,         -- non-zero indicates an error status
71
  message                VARCHAR2(1000), -- text message for this log entry
72
  harvest_operation_code VARCHAR2(30),   -- the type of harvest operation
73
  site_schedule_id       NUMBER,         -- site schedule id, or 0 if no site
74
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id)
75
);
76

  
77
/* 
78
 * harvest_detail_log -- table to log detailed info about documents that
79
 *                       generated errors during the harvest
80
 */
81
CREATE TABLE harvest_detail_log (
82
  detail_log_id          NUMBER,         -- unique id
83
  harvest_log_id         NUMBER,         -- ponter to the related log entry
84
  scope                  VARCHAR2(50),   -- document scope
85
  identifier             NUMBER,         -- document identifier
86
  revision               NUMBER,         -- document revision
87
  document_url           VARCHAR2(255),  -- document URL
88
  error_message          VARCHAR2(1000), -- text error message
89
  document_type          VARCHAR2(100),  -- document type
90
  CONSTRAINT harvest_detail_log_pk PRIMARY KEY (detail_log_id),
91
  CONSTRAINT harvest_detail_log_fk 
92
        FOREIGN KEY (harvest_log_id) REFERENCES harvest_log
93
);
94

  
95
/*
96
 * Modify the xml_index.path to the new larger size
97
 */
98
ALTER TABLE xml_index MODIFY (path VARCHAR2(1000));
99

  
100
/*
101
 * Update the XML_CATALOG table with new entries, and change old ones
102
 */
103
INSERT INTO xml_catalog (entry_type, public_id, system_id)
104
  VALUES ('Schema', '@eml2_0_1namespace@', '/schema/eml-2.0.1/eml.xsd');
105
UPDATE xml_catalog
106
  SET system_id = '/schema/eml-2.0.0/eml.xsd'
107
  WHERE public_id = '@eml2_0_0namespace@';
108
UPDATE xml_catalog
109
  SET system_id = '/schema/eml-2.0.0/stmml.xsd'
110
  WHERE public_id = '@stmmlnamespace@';
0 111

  
src/xmltables-oracle.sql
1
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2004 Regents of the University of California and the
4
 *             National Center for Ecological Analysis and Synthesis
5
 *
6
 *   '$Author$'
7
 *     '$Date$'
8
 * '$Revision$'
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 */
24

  
25
/*
26
 * Drop all of the objects in proper order
27
 */
28
set echo off
29

  
30
DROP SEQUENCE xml_nodes_id_seq;
31
DROP SEQUENCE xml_revisions_id_seq;
32
DROP SEQUENCE xml_catalog_id_seq;
33
DROP SEQUENCE xml_relation_id_seq;
34
DROP SEQUENCE xml_replication_id_seq;
35
DROP SEQUENCE identifier_id_seq;
36
DROP SEQUENCE access_log_id_seq;
37
DROP SEQUENCE xml_returnfield_id_seq;
38
DROP SEQUENCE xml_queryresult_id_seq;
39
DROP SEQUENCE xml_path_index_id_seq;
40
DROP SEQUENCE db_version_id_seq;
41

  
42
/* Drop triggers are not necessary */
43
DROP TRIGGER xml_nodes_before_insert;
44
DROP TRIGGER xml_revisions_before_insert;
45
DROP TRIGGER xml_catalog_before_insert;
46
DROP TRIGGER xml_relation_before_insert;
47
DROP TRIGGER xml_replication_before_insert;
48
DROP TRIGGER identifier_before_insert;
49
DROP TRIGGER access_log_before_insert;
50
DROP TRIGGER xml_returnfield_before_insert;
51
DROP TRIGGER xml_queryresult_before_insert;
52
DROP TRIGGER db_version_before_insert;
53

  
54

  
55
DROP TABLE xml_index;
56
DROP TABLE xml_access;
57
DROP TABLE xml_accesssubtree;
58
DROP TABLE xml_revisions;
59
DROP TABLE xml_relation;
60
DROP TABLE xml_documents CASCADE CONSTRAINTS;
61
DROP TABLE xml_nodes;
62
DROP TABLE xml_nodes_revisions;
63
DROP TABLE xml_replication;
64
DROP TABLE xml_catalog;
65
DROP TABLE identifier;
66
DROP TABLE access_log;
67
DROP TABLE harvest_site_schedule;
68
DROP TABLE harvest_detail_log;
69
DROP TABLE harvest_log;
70
DROP TABLE xml_queryresult;
71
DROP TABLE xml_returnfield;
72
DROP TABLE xml_path_index;
73
DROP TABLE db_version;
74

  
75
/*
76
 *Replication -- table to store servers that metacat is replicated to
77
 */
78
CREATE TABLE xml_replication (
79
  serverid      NUMBER(20),
80
  server        VARCHAR2(512),
81
  last_checked  DATE,
82
  replicate     NUMBER(1),
83
  datareplicate NUMBER(1),
84
  hub NUMBER(1),
85
  CONSTRAINT xml_replication_pk PRIMARY KEY (serverid)
86
);
87

  
88
CREATE SEQUENCE xml_replication_id_seq;
89
CREATE TRIGGER xml_replication_before_insert
90
BEFORE INSERT ON xml_replication FOR EACH ROW
91
BEGIN
92
  SELECT xml_replication_id_seq.nextval
93
    INTO :new.serverid
94
    FROM dual;
95
END;
96
/
97

  
98
INSERT INTO xml_replication (server, replicate, datareplicate, hub)
99
 VALUES ('localhost', '0', '0', '0');
100

  
101
/*
102
 * Nodes -- table to store XML Nodes (both elements and attributes)
103
 */
104
CREATE SEQUENCE xml_nodes_id_seq;
105
CREATE TABLE xml_nodes (
106
	nodeid		NUMBER(20),	-- the unique node id (pk)
107
	nodeindex	NUMBER(10),	-- order of nodes within parent
108
	nodetype	VARCHAR2(20),	-- type (DOCUMENT, COMMENT, PI,
109
					-- ELEMENT, ATTRIBUTE, TEXT)
110
	nodename	VARCHAR2(250),	-- the name of an element or attribute
111
	nodeprefix	VARCHAR2(50),	-- the namespace prefix of an element
112
                                        -- or attribute
113
	nodedata	VARCHAR2(4000), -- the data for this node (e.g.,
114
					-- for TEXT it is the content)
115
	parentnodeid	NUMBER(20),	-- index of the parent of this node
116
	rootnodeid	NUMBER(20),	-- index of the root node of this tree
117
	docid		VARCHAR2(250),	-- index to the document id
118
	date_created	DATE,
119
	date_updated	DATE,
120
	nodedatanumerical NUMBER,       -- the data for this node if
121
					-- it is a number
122
   CONSTRAINT xml_nodes_pk PRIMARY KEY (nodeid),
123
   CONSTRAINT xml_nodes_root_fk
124
		FOREIGN KEY (rootnodeid) REFERENCES xml_nodes,
125
   CONSTRAINT xml_nodes_parent_fk
126
		FOREIGN KEY (parentnodeid) REFERENCES xml_nodes
127
);
128
CREATE TRIGGER xml_nodes_before_insert
129
BEFORE INSERT ON xml_nodes FOR EACH ROW
130
BEGIN
131
  SELECT xml_nodes_id_seq.nextval
132
    INTO :new.nodeid
133
    FROM dual;
134
END;
135
/
136

  
137

  
138
/*
139
 * Indexes of rootnodeid, parentnodeid, and nodename in xml_nodes
140
 */
141
CREATE INDEX xml_nodes_idx1 ON xml_nodes (rootnodeid);
142
CREATE INDEX xml_nodes_idx2 ON xml_nodes (parentnodeid);
143
CREATE INDEX xml_nodes_idx3 ON xml_nodes (nodename);
144
CREATE INDEX xml_nodes_idx4 ON xml_nodes (docid);
145

  
146

  
147
/*
148
 * xml_nodes_revisions -- table to store nodes from xml_nodes which are of old revisions and deleted document
149
 */
150

  
151
CREATE TABLE xml_nodes_revisions (
152
        nodeid          NUMBER(20),     -- the unique node id (pk)
153
        nodeindex       NUMBER(10),     -- order of nodes within parent
154
        nodetype        VARCHAR2(20),   -- type (DOCUMENT, COMMENT, PI,
155
                                        -- ELEMENT, ATTRIBUTE, TEXT)
156
        nodename        VARCHAR2(250),  -- the name of an element or attribute
157
        nodeprefix      VARCHAR2(50),   -- the namespace prefix of an element
158
                                        -- or attribute
159
        nodedata        VARCHAR2(4000), -- the data for this node (e.g.,
160
                                        -- for TEXT it is the content)
161
        parentnodeid    NUMBER(20),     -- index of the parent of this node
162
        rootnodeid      NUMBER(20),     -- index of the root node of this tree
163
        docid           VARCHAR2(250),  -- index to the document id
164
        date_created    DATE,
165
        date_updated    DATE,
166
        nodedatanumerical NUMBER,       -- the data for this node if
167
                                        -- it is a number
168
   CONSTRAINT xml_nodes_revisions_pk PRIMARY KEY (nodeid),
169
   CONSTRAINT xml_nodes_revisions_root_fk
170
                FOREIGN KEY (rootnodeid) REFERENCES xml_nodes_revisions,
171
   CONSTRAINT xml_nodes_revisions_parent_fk
172
                FOREIGN KEY (parentnodeid) REFERENCES xml_nodes_revisions
173
);
174

  
175

  
176
/*
177
 * Indexes of rootnodeid, parentnodeid, and nodename in xml_nodes_revision
178
 */
179
CREATE INDEX xml_nodes_revisions_idx1 ON xml_nodes_revisions (rootnodeid);
180
CREATE INDEX xml_nodes_revisions_idx2 ON xml_nodes_revisions (parentnodeid);
181
CREATE INDEX xml_nodes_revisions_idx3 ON xml_nodes_revisions (nodename);
182

  
183
/*
184
 * XML Catalog -- table to store all external sources for XML documents
185
 */
186
CREATE TABLE xml_catalog (
187
	catalog_id	NUMBER(20),	-- the id for this catalog entry
188
	entry_type	VARCHAR2(500),	-- the type of this catalog entry
189
					-- (e.g., DTD, XSD, XSL)
190
	source_doctype	VARCHAR2(500),	-- the source public_id for transforms
191
	target_doctype	VARCHAR2(500),	-- the target public_id for transforms
192
	public_id	VARCHAR2(500),	-- the unique id for this type
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff