remove holds based on fulfillment library
[migration-tools.git] / sql / nuke-bibs-and-items.sql
1 -- Copyright 2009-2012, Equinox Software, Inc.
2 --
3 -- This program is free software; you can redistribute it and/or
4 -- modify it under the terms of the GNU General Public License
5 -- as published by the Free Software Foundation; either version 2
6 -- of the License, or (at your option) any later version.
7 --
8 -- This program is distributed in the hope that it will be useful,
9 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
10 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 -- GNU General Public License for more details.
12 --
13 -- You should have received a copy of the GNU General Public License
14 -- along with this program; if not, write to the Free Software
15 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17 BEGIN;
18
19 DROP TABLE IF EXISTS asset.call_number_temp;
20 CREATE TABLE asset.call_number_temp AS (
21   SELECT * FROM asset.call_number WHERE id = -1
22 );
23
24 DROP TABLE IF EXISTS biblio.record_entry_temp;
25 CREATE TABLE biblio.record_entry_temp AS (
26   SELECT * FROM biblio.record_entry WHERE id = -1
27 );
28
29
30 TRUNCATE
31   action.circulation,
32   asset.copy,
33   asset.opac_visible_copies,
34   biblio.record_entry,
35   asset.call_number,
36   metabib.metarecord_source_map,
37   metabib.metarecord,
38   metabib.facet_entry,
39   metabib.browse_entry,
40   authority.record_entry,
41   authority.full_rec,
42   authority.rec_descriptor
43 CASCADE;
44
45 INSERT INTO asset.call_number SELECT * FROM asset.call_number_temp;
46 INSERT INTO biblio.record_entry SELECT * FROM biblio.record_entry_temp;
47
48 DROP TABLE asset.call_number_temp;
49 DROP TABLE biblio.record_entry_temp;
50
51 \echo If the purge looks good, please COMMIT
52 \echo You should also follow with a VACUUM ANALYZE or the like.
53