Utilities to nuke data
[migration-tools.git] / sql / nuke-bibs-and-items.sql
diff --git a/sql/nuke-bibs-and-items.sql b/sql/nuke-bibs-and-items.sql
new file mode 100644 (file)
index 0000000..f88bf93
--- /dev/null
@@ -0,0 +1,26 @@
+BEGIN;
+
+DROP TABLE IF EXISTS asset.call_number_temp;
+CREATE TABLE asset.call_number_temp AS (
+  SELECT * FROM asset.call_number WHERE id = -1
+);
+
+DROP TABLE IF EXISTS biblio.record_entry_temp;
+CREATE TABLE biblio.record_entry_temp AS (
+  SELECT * FROM biblio.record_entry WHERE id = -1
+);
+
+
+TRUNCATE
+  action.circulation,
+  asset.copy,
+  biblio.record_entry,
+  asset.call_number,
+  metabib.metarecord_source_map,
+  metabib.metarecord
+CASCADE;
+
+INSERT INTO asset.call_number SELECT * FROM asset.call_number_temp;
+INSERT INTO biblio.record_entry SELECT * FROM biblio.record_entry_temp;
+
+