BEFORE UPDATE ON asset.copy
FOR EACH ROW EXECUTE PROCEDURE asset.acp_status_changed();
-CREATE TABLE asset.copy_transparency (
- id SERIAL PRIMARY KEY,
- deposit_amount NUMERIC(6,2),
- owner INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED,
- circ_lib INT REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED,
- loan_duration INT CHECK ( loan_duration IN (1,2,3) ),
- fine_level INT CHECK ( fine_level IN (1,2,3) ),
- holdable BOOL,
- circulate BOOL,
- deposit BOOL,
- ref BOOL,
- opac_visible BOOL,
- circ_modifier TEXT,
- circ_as_type TEXT,
- name TEXT NOT NULL,
- CONSTRAINT scte_name_once_per_lib UNIQUE (owner,name)
-);
-
-CREATE TABLE asset.copy_transparency_map (
- id BIGSERIAL PRIMARY KEY,
- transparency INT NOT NULL REFERENCES asset.copy_transparency (id) DEFERRABLE INITIALLY DEFERRED,
- target_copy INT NOT NULL UNIQUE REFERENCES asset.copy (id) DEFERRABLE INITIALLY DEFERRED
-);
-CREATE INDEX cp_tr_cp_idx ON asset.copy_transparency_map (transparency);
-
CREATE TABLE asset.stat_cat_entry_transparency_map (
id BIGSERIAL PRIMARY KEY,
stat_cat INT NOT NULL, -- needs ON DELETE CASCADE
--- /dev/null
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0301'); -- gmc
+
+CREATE TEMPORARY TABLE eg_0301_check_if_has_contents (
+ flag INTEGER PRIMARY KEY
+) ON COMMIT DROP;
+INSERT INTO eg_0301_check_if_has_contents VALUES (1);
+
+-- cause failure if either of the tables we want to drop have rows
+INSERT INTO eg_0301_check_if_has_contents SELECT 1 FROM asset.copy_transparency LIMIT 1;
+INSERT INTO eg_0301_check_if_has_contents SELECT 1 FROM asset.copy_transparency_map LIMIT 1;
+
+DROP TABLE asset.copy_transparency_map;
+DROP TABLE asset.copy_transparency;
+
+COMMIT;