mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 13:33:08 +00:00

(SF bug #495059) - SQL file separated into database_schema.sql, for creating the schema, clean-database.sql, which removes tables, views etc. from an existing DSpace database, and update-sequences.sql which resets the ID generators, but is only used after an SQL dump which sets explicit primary keys. - Sequences for primary key generation added to SQL schema - SQL function "getnextid" added as an abstraction for access to those sequences - Database manager now uses getnextid() SQL function to get IDs - this means other DB backends can hide ID generation specifics behind this - Minor tweak to HistoryManager, which was accessing DB manager's in-memory ID generator directly - now it doesn't do this. - Old, now unnecessary "reset ID generator" admin servlet/JSP removed git-svn-id: http://scm.dspace.org/svn/repo/trunk@362 9c30dcfa-912a-0410-8fc2-9e0234be79fd
130 lines
4.3 KiB
SQL
130 lines
4.3 KiB
SQL
--
|
|
-- clean-database.sql
|
|
--
|
|
-- Version: $Revision$
|
|
--
|
|
-- Date: $Date$
|
|
--
|
|
-- Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
|
|
-- Institute of Technology. All rights reserved.
|
|
--
|
|
-- Redistribution and use in source and binary forms, with or without
|
|
-- modification, are permitted provided that the following conditions are
|
|
-- met:
|
|
--
|
|
-- - Redistributions of source code must retain the above copyright
|
|
-- notice, this list of conditions and the following disclaimer.
|
|
--
|
|
-- - Redistributions in binary form must reproduce the above copyright
|
|
-- notice, this list of conditions and the following disclaimer in the
|
|
-- documentation and/or other materials provided with the distribution.
|
|
--
|
|
-- - Neither the name of the Hewlett-Packard Company nor the name of the
|
|
-- Massachusetts Institute of Technology nor the names of their
|
|
-- contributors may be used to endorse or promote products derived from
|
|
-- this software without specific prior written permission.
|
|
--
|
|
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
-- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
-- HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
-- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
-- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
-- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
-- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
-- DAMAGE.
|
|
|
|
--
|
|
-- DSpace database cleaner
|
|
--
|
|
-- This SQL "cleans" a database used by a DSpace installation. It removes
|
|
-- all tables etc. so the database is completely empty and ready for a
|
|
-- fresh installation. Of course, this means all data is lost.
|
|
--
|
|
-- Caution: THIS IS POSTGRESQL-SPECIFC
|
|
-- * The sequences dropped below are automatically created by PostgreSQL
|
|
-- for the SERIAL typed fields.
|
|
--
|
|
-- This should be kept in sync if database_schema.sql is updated.
|
|
|
|
|
|
-- Drop indices
|
|
DROP INDEX dcvalue_dc_type_id_idx;
|
|
|
|
-- Drop the views
|
|
DROP VIEW CommunityItemsByDateAccessioned;
|
|
DROP VIEW CollectionItemsByDateAccessioned;
|
|
DROP VIEW CommunityItemsByDate;
|
|
DROP VIEW CollectionItemsByDate;
|
|
DROP VIEW CommunityItemsByTitle;
|
|
DROP VIEW CollectionItemsByTitle;
|
|
DROP VIEW CommunityItemsByAuthor;
|
|
DROP VIEW CollectionItemsByAuthor;
|
|
DROP VIEW Community2Item;
|
|
|
|
-- Then the tables
|
|
DROP TABLE ItemsByDateAccessioned;
|
|
DROP TABLE ItemsByDate;
|
|
DROP TABLE ItemsByTitle;
|
|
DROP TABLE ItemsByAuthor;
|
|
DROP TABLE HistoryState;
|
|
DROP TABLE History;
|
|
DROP TABLE RegistrationData;
|
|
DROP TABLE TasklistItem;
|
|
DROP TABLE WorkflowItem;
|
|
DROP TABLE WorkspaceItem;
|
|
DROP TABLE Handle;
|
|
DROP TABLE EPersonGroup2EPerson;
|
|
DROP TABLE ResourcePolicy;
|
|
DROP TABLE Collection2Item;
|
|
DROP TABLE Community2Collection;
|
|
DROP TABLE Collection;
|
|
DROP TABLE Community;
|
|
DROP TABLE DCValue;
|
|
DROP TABLE DCTypeRegistry;
|
|
DROP TABLE Bundle2Bitstream;
|
|
DROP TABLE Item2Bundle;
|
|
DROP TABLE Bundle;
|
|
DROP TABLE Item;
|
|
DROP TABLE EPersonGroup;
|
|
DROP TABLE EPerson;
|
|
DROP TABLE Bitstream;
|
|
DROP TABLE FileExtension;
|
|
DROP TABLE BitstreamFormatRegistry;
|
|
|
|
-- Now drop the sequences for ID (primary key) creation
|
|
DROP SEQUENCE bitstreamformatregistry_seq;
|
|
DROP SEQUENCE fileextension_seq;
|
|
DROP SEQUENCE bitstream_seq;
|
|
DROP SEQUENCE eperson_seq;
|
|
DROP SEQUENCE epersongroup_seq;
|
|
DROP SEQUENCE item_seq;
|
|
DROP SEQUENCE bundle_seq;
|
|
DROP SEQUENCE item2bundle_seq;
|
|
DROP SEQUENCE bundle2bitstream_seq;
|
|
DROP SEQUENCE dctyperegistry_seq;
|
|
DROP SEQUENCE dcvalue_seq;
|
|
DROP SEQUENCE community_seq;
|
|
DROP SEQUENCE collection_seq;
|
|
DROP SEQUENCE community2collection_seq;
|
|
DROP SEQUENCE collection2item_seq;
|
|
DROP SEQUENCE resourcepolicy_seq;
|
|
DROP SEQUENCE epersongroup2eperson_seq;
|
|
DROP SEQUENCE handle_seq;
|
|
DROP SEQUENCE workspaceitem_seq;
|
|
DROP SEQUENCE workflowitem_seq;
|
|
DROP SEQUENCE tasklistitem_seq;
|
|
DROP SEQUENCE registrationdata_seq;
|
|
DROP SEQUENCE history_seq;
|
|
DROP SEQUENCE historystate_seq;
|
|
DROP SEQUENCE itemsbyauthor_seq;
|
|
DROP SEQUENCE itemsbytitle_seq;
|
|
DROP SEQUENCE itemsbydate_seq;
|
|
DROP SEQUENCE itemsbydateaccessioned_seq;
|
|
|
|
-- Drop the getnextid() function
|
|
DROP FUNCTION getnextid(VARCHAR(40));
|