Adding PINES datawork to pre-upgrade script.
authorChris Sharp <csharp@georgialibraries.org>
Mon, 13 Jan 2014 18:31:37 +0000 (13:31 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Mon, 20 Oct 2014 12:49:13 +0000 (08:49 -0400)
Open-ILS/src/sql/Pg/version-upgrade/pines-pre-2.3-2.4.0-upgrade-db.sql

index c5cbc82..cc22f87 100644 (file)
@@ -11,4 +11,32 @@ UPDATE config.copy_status SET name = 'Long Overdue (Legacy)' WHERE name = 'Long
 DROP FUNCTION search.staged_fts(integer,integer,text,integer[],text[],text[],text[],text[],text[],text[],text,real,text,boolean,boolean,boolean,integer,integer,integer);
 DROP AGGREGATE agg_tsvector(public.tsvector);
 DROP FUNCTION tsvector_concat(public.tsvector,public.tsvector);
+
+-- delete empty volumes over 1 month old  - real    3m38.936s on test
+UPDATE asset.call_number acn SET deleted = TRUE WHERE NOT acn.deleted AND acn.id NOT IN (SELECT acp.call_number FROM asset.copy acp WHERE NOT acp.deleted) AND acn.create_date < (now() - interval '1 month');
+
+-- delete empty bibs over 1 month old - real    1m23.544s on test
+UPDATE biblio.record_entry bre SET deleted = TRUE WHERE NOT bre.deleted and bre.id NOT IN (SELECT acn.record FROM asset.call_number acn WHERE NOT acn.deleted) AND bre.create_date < (now() - interval '1 month');
+
+-- delete Missing items over one year old
+UPDATE asset.copy SET deleted = TRUE WHERE NOT deleted AND status IN (SELECT id FROM config.copy_status WHERE name = 'Missing') AND edit_date <= (now() - interval '1 year');
+
+-- delete the circ modifiers that never seem to actually go away...
+UPDATE asset.copy SET circ_modifier = 'bestseller' WHERE circ_modifier = 'bestsellernh';
+UPDATE asset.copy SET circ_modifier = 'av' WHERE circ_modifier IN ('filmstrip', 'new-av');
+UPDATE asset.copy SET circ_modifier = NULL WHERE circ_modifier IN ('computer', 'internet', 'internethg', 'internethm');
+
+DELETE FROM config.circ_matrix_matchpoint WHERE circ_modifier IN ('bestsellernh', 'filmstrip', 'new-av', 'computer', 'internet');
+DELETE FROM config.hold_matrix_matchpoint WHERE circ_modifier IN ('bestsellernh', 'filmstrip', 'new-av', 'computer', 'internet');
+
+DELETE FROM config.circ_modifier WHERE code IN ('bestsellernh', 'filmstrip', 'new-av', 'computer', 'internet', 'internethg', 'internethm');
+
+VACUUM ANALYZE asset.call_number;
+VACUUM ANALYZE biblio.record_entry;
+VACUUM ANALYZE asset.copy;
+VACUUM ANALYZE config.circ_matrix_matchpoint;
+VACUUM ANALYZE config.hold_matrix_matchpoint;
+VACUUM ANALYZE config.circ_modifier;
+VACUUM ANALYZE config.copy_status;
+
 COMMIT;