Project

General

Profile

« Previous | Next » 

Revision 1827

Added by Matt Jones over 20 years ago

Renamed the upgrade sql files to more understandable names, updated the
build file to include some new targets for running these files, and
updated the installation docs to clarify which upgrade scripts need to
be run and when.

View differences:

src/xmlreplicationtable_postgres.sql
1
/*
2
 * xmlreplicationtables_postgres.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 COLUMN datareplicate INT8;
20
ALTER TABLE xml_replication ADD COLUMN hub INT8;
21

  
22 0

  
src/reviseformetacat13_postgres.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

  
27
CREATE TABLE xml_accesssubtree (
28
	docid		VARCHAR(250),	-- the document id #
29
  rev 		INT8 default 1, --the revision number of the docume
30
  controllevel VARCHAR(50), -- the level it control -- document or subtree
31
  subtreeid VARCHAR(250), -- the subtree id 
32
	startnodeid	INT8,	-- the start node id of access subtree
33
  endnodeid INT8, -- the end node if of access subtree
34
  CONSTRAINT xml_accesssubtree_docid_fk 
35
		FOREIGN KEY (docid) REFERENCES xml_documents
36
);
37

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

  
66

  
67 0

  
src/reviseformetacat13.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/xmlreplicationtable.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.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

  
0 21

  
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); 
0 41

  
src/upgrade-db-to-1.2_postgres.sql
1
/*
2
 * xmlreplicationtables_postgres.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 COLUMN datareplicate INT8;
20
ALTER TABLE xml_replication ADD COLUMN hub INT8;
21

  
0 22

  
src/upgrade-db-to-1.3_postgres.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

  
27
CREATE TABLE xml_accesssubtree (
28
	docid		VARCHAR(250),	-- the document id #
29
  rev 		INT8 default 1, --the revision number of the docume
30
  controllevel VARCHAR(50), -- the level it control -- document or subtree
31
  subtreeid VARCHAR(250), -- the subtree id 
32
	startnodeid	INT8,	-- the start node id of access subtree
33
  endnodeid INT8, -- the end node if of access subtree
34
  CONSTRAINT xml_accesssubtree_docid_fk 
35
		FOREIGN KEY (docid) REFERENCES xml_documents
36
);
37

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

  
66

  
0 67

  
docs/user/metacatinstall.html
303 303
  </p>
304 304
  <p class="header"><h2>SQL Scripts</h2></p>
305 305
  <p>
306
   You now need to set up the table structure in your database.  Change to the
306
   You now need to set up the table structure in your database.  You can do
307
   either do this using the ant build system, or by manually running the
308
   scripts using a sql utility.
309
  </p>
310
  <p>To run the scripts using ant, type "ant installdb".
311
  </p>
312
  <p>To run the scripts manually, change to the
307 313
   metacat/src directory.  Then run you RDBMS's SQL utility.  In Oracle it is
308 314
   SQLPlus.  This tutorial assumes an Oracle database so this example is for
309 315
   SQLPlus.  Login as the oracle user that was set up for use with Metacat.
310 316
   At the SQLPlus prompt type the following: <pre><b>@xmltables.sql;</b></pre>
311
   You should see a bunch of output showing the creation of the Metacat table
317
  </p>
318
  <p>Either way, 
319
   you should see a bunch of output showing the creation of the Metacat table
312 320
   space. The first time you run this script you will get several errors at the 
313 321
   beginning saying that you cannot drop a table/index/trigger because it 
314 322
   does not exist.  This is normal.  Any other errors besides this need to be
315 323
   resolved before continuing. The script file name for PostgreSQL is 
316
   xmltalbes_postgres.sql and for Microsoft SQL server is xmltables-sqlserver.sql.
324
   xmltalbes_postgres.sql and for Microsoft SQL server is 
325
   xmltables-sqlserver.sql.
317 326
  </p>
318 327
  <p>
319 328
   If the script has run correctly you should be able to type 
......
336 345
     UPDATED                      NUMBER(1)
337 346
   </pre>
338 347
  </p>
348
  <p class="header"><h2>Upgrading SQL Scripts</h2></p>
349
  <p>
350
    If you have an existing metacat installation, you should not run the install
351
    script because it will replace all of the older tables with new, empty 
352
    copies of the tables.  Thus you would lose your data!  Instead, you can 
353
    run some upgrade scripts that will change the table structure as needed for
354
    the new version.  If you are skipping versions, run each upgrade script
355
    for the intermediate versions as well.  Currently the upgrade scripts are:
356
   </p>
357
    <ul>
358
      <li>upgrade-db-to-1.2.sql</li>
359
      <li>upgrade-db-to-1.3.sql</li>
360
    </ul>
361
   <p>
362
    So, if you had an existing metacat 1.0 installation and you were upgrading 
363
    to 1.3, you would need to run both upgrade-db-to-1.2.sql and 
364
    upgrade-db-to-1.3.sql. Howver, if you were starting from a Metacat 1.2.x
365
    installation, you would only need to run the 1.3 upgrade script.
366
   </p>
367
  </p>
339 368
</td>
340 369
</tr>
341 370
</table>
build.xml
75 75

  
76 76
      <!-- Customize these properties for your system -->
77 77
      <property name="tomcat" value="/usr/local/devtools/jakarta-tomcat" />
78
      <property name="webapps" value="/usr/local/devtools/jakarta-tomcat/webapps" />
78
      <property name="webapps" value="${tomcat}/webapps" />
79 79
      <property name="context" value="tao" />
80 80
      <property name="user" value="knb"/>
81 81
      <property name="password" value="tdataint"/>
......
90 90
      <property name="tomcatversion" value="tomcat4"/>
91 91

  
92 92
      <property name="server" value="pine.nceas.ucsb.edu:8080"/>
93
      <property name="systemidserver" value="http://pine.nceas.ucsb.edu:8080" />
93
      <property name="systemidserver" value="http://${server}" />
94 94
      <property name="datafilepath" value="/usr/local/devtools/jakarta-tomcat/data/tao/data" />
95 95
      <property name="inlinedatafilepath" value="/usr/local/devtools/jakarta-tomcat/data/tao/inlinedata" />
96
      <property name="debug" value="on" />
96 97
      <property name="debuglevel" value="55" />
97 98

  
98 99
      <property name="forcereplicationwaitingtime" value="30000"/>
......
245 246
       <javac srcdir="${build.src}"
246 247
              destdir="${build.dest}"
247 248
              classpath="${cpath}"
249
              debug="${debug}"
248 250
              excludes="**/*.sql **/stringclient/** **/client/*.java"/>
249 251
       <copy file="lib/metacat.properties"
250 252
             tofile="${build.dest}/${package.home}/metacat.properties"
......
375 377
          src="${build.src}/loadschema.sql" />
376 378
   </target>
377 379
   
380
   <target name="installdb" depends="prepare">
381
     <echo/>
382
     <echo>Installing the database tables...</echo>
383
     <sql driver="${dbDriver}"
384
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
385
          url="${jdbc-connect}"
386
          userid="${user}"
387
          password="${password}"
388
          src="${build.src}/xmltables.sql" />
389
   </target>
390

  
391
   <target name="upgrade12" depends="prepare">
392
     <echo/>
393
     <echo>Updating the database tables to upgrade to version 1.2...</echo>
394
     <sql driver="${dbDriver}"
395
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
396
          url="${jdbc-connect}"
397
          userid="${user}"
398
          password="${password}"
399
          src="${build.src}/upgrade-db-to-1.2.sql" />
400
   </target>
401

  
402
   <target name="upgrade13" depends="prepare">
403
     <echo/>
404
     <echo>Updating the database tables to upgrade to version 1.3...</echo>
405
     <sql driver="${dbDriver}"
406
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
407
          url="${jdbc-connect}"
408
          userid="${user}"
409
          password="${password}"
410
          src="${build.src}/upgrade-db-to-1.3.sql" />
411
   </target>
412

  
378 413
   <target name="installCommon" depends="jar">
379 414
       <mkdir dir="${datafilepath}" />
380 415
       <mkdir dir="${inlinedatafilepath}" />

Also available in: Unified diff