[open-ils-commits] r10760 - trunk/Open-ILS/src/extras/import
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Oct 6 07:27:52 EDT 2008
Author: miker
Date: 2008-10-06 07:27:52 -0400 (Mon, 06 Oct 2008)
New Revision: 10760
Modified:
trunk/Open-ILS/src/extras/import/quick_metarecord_map.sql
Log:
safer MR mapping
Modified: trunk/Open-ILS/src/extras/import/quick_metarecord_map.sql
===================================================================
--- trunk/Open-ILS/src/extras/import/quick_metarecord_map.sql 2008-10-06 03:40:01 UTC (rev 10759)
+++ trunk/Open-ILS/src/extras/import/quick_metarecord_map.sql 2008-10-06 11:27:52 UTC (rev 10760)
@@ -1,31 +1,23 @@
BEGIN;
-ALTER TABLE metabib.metarecord_source_map DROP CONSTRAINT metabib_metarecord_source_map_metarecord_fkey;
-
-TRUNCATE metabib.metarecord;
-TRUNCATE metabib.metarecord_source_map;
-
INSERT INTO metabib.metarecord (fingerprint,master_record)
SELECT fingerprint,id
FROM (SELECT DISTINCT ON (fingerprint)
fingerprint, id, quality
FROM biblio.record_entry
ORDER BY fingerprint, quality desc) AS x
- WHERE fingerprint IS NOT NULL;
+ WHERE fingerprint IS NOT NULL
+ AND fingerprint NOT IN ( SELECT fingerprint FROM metabib.metarecord);
INSERT INTO metabib.metarecord_source_map (metarecord,source)
SELECT m.id, b.id
FROM biblio.record_entry b
- JOIN metabib.metarecord m ON (m.fingerprint = b.fingerprint);
+ JOIN metabib.metarecord m ON (m.fingerprint = b.fingerprint)
+ LEFT JOIN metabib.metarecord_source_map s ON (b.id = s.source)
+ WHERE s.id IS NULL;
COMMIT;
-BEGIN;
-
-ALTER TABLE metabib.metarecord_source_map ADD CONSTRAINT metabib_metarecord_source_map_metarecord_fkey FOREIGN KEY (metarecord) REFERENCES metabib.metarecord (id) DEFERRABLE INITIALLY DEFERRED;
-
-COMMIT;
-
VACUUM FULL ANALYZE VERBOSE metabib.metarecord;
VACUUM FULL ANALYZE VERBOSE metabib.metarecord_source_map;
More information about the open-ils-commits
mailing list