LP1737016: Ease Constraints on afs.code
authorJason Boyer <JBoyer@library.in.gov>
Thu, 7 Dec 2017 19:45:21 +0000 (14:45 -0500)
committerDan Wells <dbw2@calvin.edu>
Tue, 27 Feb 2018 21:06:18 +0000 (16:06 -0500)
acq.funding_source.code currently has a UNIQUE
constraint applied, which can be confusing to
users. This branch only requires that a code be
unique to the funding source's owner, simplifying
the management of funding sources.

Signed-off-by: Jason Boyer <JBoyer@library.in.gov>
Signed-off-by: Remington Steed <rjs7@calvin.edu>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/sql/Pg/200.schema.acq.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1737016_afs_code.sql [new file with mode: 0644]
docs/RELEASE_NOTES_NEXT/Acquisitions/RELEASE_NOTE_TEMPLATE.adoc [new file with mode: 0644]

index c0670bb..60088d1 100644 (file)
@@ -154,7 +154,8 @@ CREATE TABLE acq.funding_source (
        name            TEXT    NOT NULL,
        owner           INT     NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED,
        currency_type   TEXT    NOT NULL REFERENCES acq.currency_type (code) DEFERRABLE INITIALLY DEFERRED,
-       code            TEXT    UNIQUE,
+       code            TEXT    NOT NULL,
+       CONSTRAINT funding_source_code_once_per_owner UNIQUE (code,owner),
        CONSTRAINT funding_source_name_once_per_owner UNIQUE (name,owner)
 );
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1737016_afs_code.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1737016_afs_code.sql
new file mode 100644 (file)
index 0000000..bea3fb5
--- /dev/null
@@ -0,0 +1,9 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+ALTER TABLE acq.funding_source DROP CONSTRAINT funding_source_code_key;
+ALTER TABLE acq.funding_source ALTER COLUMN code SET NOT NULL;
+ALTER TABLE acq.funding_source ADD CONSTRAINT funding_source_code_once_per_owner UNIQUE (code,owner);
+
+COMMIT;
diff --git a/docs/RELEASE_NOTES_NEXT/Acquisitions/RELEASE_NOTE_TEMPLATE.adoc b/docs/RELEASE_NOTES_NEXT/Acquisitions/RELEASE_NOTE_TEMPLATE.adoc
new file mode 100644 (file)
index 0000000..82c3b23
--- /dev/null
@@ -0,0 +1,9 @@
+Funding Source Codes are now Unique per Owner
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Funding source codes had to be unique across an
+entire installation which is aggravating when
+you can't actually see the other source codes.
+
+Now multiple locations can have the same codes if
+they desire.
+