From: Jason Stephenson Date: Fri, 3 Mar 2023 20:53:17 +0000 (-0500) Subject: LP 2009066: Set invoice_item_fund_debit_fkey Deferrable X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=57c709e6c35252a23c7f9c98f85a38e54ea2eae8;p=working%2FEvergreen.git LP 2009066: Set invoice_item_fund_debit_fkey Deferrable Make the foreign key relationship between acq.invoice_item and acq.fund_debit deferrable so that fund debits can be deleted in the same transactions as the invoice items. Otherwise, the fund debits cannot be deleted if at all if referenced by an invoice item. Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/sql/Pg/200.schema.acq.sql b/Open-ILS/src/sql/Pg/200.schema.acq.sql index 3195feec61..508a761103 100644 --- a/Open-ILS/src/sql/Pg/200.schema.acq.sql +++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql @@ -924,7 +924,7 @@ CREATE TABLE acq.invoice_item ( -- for invoice-only debits: taxes/fees/non-bib i id SERIAL PRIMARY KEY, invoice INT NOT NULL REFERENCES acq.invoice (id) ON UPDATE CASCADE ON DELETE CASCADE, purchase_order INT REFERENCES acq.purchase_order (id) ON UPDATE CASCADE ON DELETE SET NULL, - fund_debit INT REFERENCES acq.fund_debit (id), + fund_debit INT REFERENCES acq.fund_debit (id) DEFERRABLE INITIALLY DEFERRED, inv_item_type TEXT NOT NULL REFERENCES acq.invoice_item_type (code), title TEXT, author TEXT, diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-invoice_item_fund_debit_fkey-deferrable.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-invoice_item_fund_debit_fkey-deferrable.sql new file mode 100644 index 0000000000..cd39f0e390 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-invoice_item_fund_debit_fkey-deferrable.sql @@ -0,0 +1,7 @@ +BEGIN; + +--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +ALTER TABLE acq.invoice_item ALTER CONSTRAINT invoice_item_fund_debit_fkey DEFERRABLE INITIALLY DEFERRED; + +COMMIT; diff --git a/docs/RELEASE_NOTES_NEXT/miscellaneous.adoc b/docs/RELEASE_NOTES_NEXT/miscellaneous.adoc index d417d853f5..7ad8d21309 100644 --- a/docs/RELEASE_NOTES_NEXT/miscellaneous.adoc +++ b/docs/RELEASE_NOTES_NEXT/miscellaneous.adoc @@ -9,3 +9,4 @@ * `autogen.sh` can now accept a `-c` switch to specify the location of `opensrf_core.xml`. This is useful for certain multi-tenant setups of Evergreen. (LP#2003707) * Better organization of acquisitions line item alert fields (LP#2002977) * Prevent templates from applying or changing magical status in angular holdings editor (LP#1999401) +* Make the foreign key relationship between the acq.invoice_item and acq.fund_debit tables deferrable so that fund debits can be deleted when they reference invoice items that are deleted in the same transaction. (LP#2009066)