Link z39.50 use_perm column to perm_list.id
authorBill Erickson <berick@esilibrary.com>
Mon, 22 Aug 2011 20:28:37 +0000 (16:28 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 22 Aug 2011 20:28:37 +0000 (16:28 -0400)
... instead of code, to take full advantage of AutoFieldWidget linking,
at least until perm_list.id is replaced wholesale w/ perm_list.code.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/800.fkeys.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.czs_use_perm_column.sql

index 8498819..c3c6eaf 100644 (file)
@@ -441,7 +441,7 @@ CREATE TABLE config.z3950_source (
     record_format       TEXT    NOT NULL DEFAULT 'FI',
     transmission_format TEXT    NOT NULL DEFAULT 'usmarc',
     auth                BOOL    NOT NULL DEFAULT TRUE,
-    use_perm            TEXT    REFERENCES permission.perm_list (code)
+    use_perm            INT     -- REFERENCES permission.perm_list (id)
 );
 
 COMMENT ON TABLE config.z3950_source IS $$
index 4395c64..3777df3 100644 (file)
@@ -122,4 +122,6 @@ ALTER TABLE config.barcode_completion ADD CONSTRAINT config_barcode_completion_o
 CREATE INDEX by_heading_and_thesaurus ON authority.record_entry (authority.normalize_heading(marc)) WHERE deleted IS FALSE or deleted = FALSE;
 CREATE INDEX by_heading ON authority.record_entry (authority.simple_normalize_heading(marc)) WHERE deleted IS FALSE or deleted = FALSE;
 
+ALTER TABLE config.z3950_source ADD CONSTRAINT use_perm_fkey FOREIGN KEY (use_perm) REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED;
+
 COMMIT;
index be4bf19..db1f077 100644 (file)
@@ -10,8 +10,8 @@ BEGIN;
 -- check whether patch can be applied
 SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
 
-ALTER TABLE config.z3950_source
-    ADD COLUMN use_perm TEXT REFERENCES permission.perm_list (code)
+ALTER TABLE config.z3950_source 
+    ADD COLUMN use_perm INT REFERENCES permission.perm_list (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 
 COMMENT ON COLUMN config.z3950_source.use_perm IS $$
 If set, this permission is required for the source to be listed in the staff