From: Jason Stephenson Date: Fri, 13 Nov 2015 21:12:46 +0000 (-0500) Subject: LP#1513554 - Stamping Upgrade Script X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0fd044ba5e38344d6aa3e0f201d84467e9925093;p=evergreen%2Fpines.git LP#1513554 - Stamping Upgrade Script Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 3a009eaaaa..31f73c4785 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps BEFORE INSERT OR UPDATE ON config.db_patch_dependencies FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates'); -INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0948', :eg_version); -- miker/gmcharlt/remington/bshum +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0949', :eg_version); -- csharp/kmlussier/dyrcona CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0949.schema.no_delete_acq_cancel_reasons.sql b/Open-ILS/src/sql/Pg/upgrade/0949.schema.no_delete_acq_cancel_reasons.sql new file mode 100644 index 0000000000..eeceaf7631 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0949.schema.no_delete_acq_cancel_reasons.sql @@ -0,0 +1,21 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('0949', :eg_version); + +CREATE OR REPLACE FUNCTION evergreen.protect_reserved_rows_from_delete() RETURNS trigger AS $protect_reserved$ +BEGIN +IF OLD.id < TG_ARGV[0]::INT THEN + RAISE EXCEPTION 'Cannot delete row with reserved ID %', OLD.id; +END IF; +END +$protect_reserved$ +LANGUAGE plpgsql; + +DROP TRIGGER IF EXISTS acq_no_deleted_reserved_cancel_reasons ON acq.cancel_reason; + +CREATE TRIGGER acq_no_deleted_reserved_cancel_reasons BEFORE DELETE ON acq.cancel_reason + FOR EACH ROW EXECUTE PROCEDURE evergreen.protect_reserved_rows_from_delete(2000); + +ALTER TABLE acq.cancel_reason ENABLE TRIGGER acq_no_deleted_reserved_cancel_reasons; + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no_delete_acq_cancel_reasons.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no_delete_acq_cancel_reasons.sql deleted file mode 100644 index 54581fcb4a..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no_delete_acq_cancel_reasons.sql +++ /dev/null @@ -1,21 +0,0 @@ -BEGIN; - -SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); - -CREATE OR REPLACE FUNCTION evergreen.protect_reserved_rows_from_delete() RETURNS trigger AS $protect_reserved$ -BEGIN -IF OLD.id < TG_ARGV[0]::INT THEN - RAISE EXCEPTION 'Cannot delete row with reserved ID %', OLD.id; -END IF; -END -$protect_reserved$ -LANGUAGE plpgsql; - -DROP TRIGGER IF EXISTS acq_no_deleted_reserved_cancel_reasons ON acq.cancel_reason; - -CREATE TRIGGER acq_no_deleted_reserved_cancel_reasons BEFORE DELETE ON acq.cancel_reason - FOR EACH ROW EXECUTE PROCEDURE evergreen.protect_reserved_rows_from_delete(2000); - -ALTER TABLE acq.cancel_reason ENABLE TRIGGER acq_no_deleted_reserved_cancel_reasons; - -COMMIT;