From eece5f0aeb11fa46bd088ff9643be48925892fb2 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Tue, 20 Mar 2012 13:03:21 -0400 Subject: [PATCH] fix constraint syntax and add in toolbar related permissions, plus a missing and unrelated perm: IMPORT_AUTHORITY_MARC Signed-off-by: Jason Etheridge --- Open-ILS/src/sql/Pg/005.schema.actors.sql | 6 +++--- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 9 +++++++-- Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql | 13 ++++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/sql/Pg/005.schema.actors.sql b/Open-ILS/src/sql/Pg/005.schema.actors.sql index 4fead81a7c..a6edeb935b 100644 --- a/Open-ILS/src/sql/Pg/005.schema.actors.sql +++ b/Open-ILS/src/sql/Pg/005.schema.actors.sql @@ -637,9 +637,6 @@ CREATE TABLE actor.toolbar ( usr INT REFERENCES actor.usr (id) ON DELETE CASCADE, label TEXT NOT NULL, layout TEXT NOT NULL, - CONSTRAINT label_once_per_ws UNIQUE (ws, label) WHERE ws IS NOT NULL, - CONSTRAINT label_once_per_org UNIQUE (org, label) WHERE org IS NOT NULL, - CONSTRAINT label_once_per_usr UNIQUE (usr, label) WHERE usr IS NOT NULL, CONSTRAINT only_one_type CHECK ( (ws IS NOT NULL AND COALESCE(org,usr) IS NULL) OR (org IS NOT NULL AND COALESCE(ws,usr) IS NULL) OR @@ -647,5 +644,8 @@ CREATE TABLE actor.toolbar ( ), CONSTRAINT layout_must_be_json CHECK ( is_json(layout) ) ); +CREATE UNIQUE INDEX label_once_per_ws ON actor.toolbar (ws, label) WHERE ws IS NOT NULL; +CREATE UNIQUE INDEX label_once_per_org ON actor.toolbar (org, label) WHERE org IS NOT NULL; +CREATE UNIQUE INDEX label_once_per_usr ON actor.toolbar (usr, label) WHERE usr IS NOT NULL; COMMIT; diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index cec8061c80..0812665d6b 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -1533,8 +1533,11 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES ( 521, 'IMPORT_ACQ_LINEITEM_BIB_RECORD_UPLOAD', oils_i18n_gettext( 521, 'Allows a user to create new bibs directly from an ACQ MARC file upload', 'ppl', 'description' )), ( 522, 'IMPORT_AUTHORITY_MARC', oils_i18n_gettext( 522, - 'Allows a user to create new authority records', 'ppl', 'description' )); - + 'Allows a user to create new authority records', 'ppl', 'description' )), + ( 523, 'VIEW_TOOLBAR', oils_i18n_gettext( 523, + 'Allows a user to view and use custom toolbars', 'ppl', 'description' )), + ( 524, 'ADMIN_TOOLBAR', oils_i18n_gettext( 524, + 'Allows a user to create, edit, and delete custom toolbars', 'ppl', 'description' )); SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000); @@ -1718,6 +1721,7 @@ INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) 'VIEW_CIRCULATIONS', 'VIEW_ORG_SETTINGS', 'VIEW_PERMIT_CHECKOUT', + 'VIEW_TOOLBAR', 'VIEW_USER', 'VIEW_USER_FINES_SUMMARY', 'VIEW_USER_TRANSACTIONS'); @@ -1743,6 +1747,7 @@ INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) 'RENEW_HOLD_OVERRIDE', 'UPDATE_COPY', 'UPDATE_VOLUME', + 'ADMIN_TOOLBAR', 'VOLUME_HOLDS'); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql index ae94191446..c16f25b6dc 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql @@ -6,9 +6,6 @@ CREATE TABLE actor.toolbar ( usr INT REFERENCES actor.usr (id) ON DELETE CASCADE, label TEXT NOT NULL, layout TEXT NOT NULL, - CONSTRAINT label_once_per_ws UNIQUE (ws, label) WHERE ws IS NOT NULL, - CONSTRAINT label_once_per_org UNIQUE (org, label) WHERE org IS NOT NULL, - CONSTRAINT label_once_per_usr UNIQUE (usr, label) WHERE usr IS NOT NULL, CONSTRAINT only_one_type CHECK ( (ws IS NOT NULL AND COALESCE(org,usr) IS NULL) OR (org IS NOT NULL AND COALESCE(ws,usr) IS NULL) OR @@ -16,4 +13,14 @@ CREATE TABLE actor.toolbar ( ), CONSTRAINT layout_must_be_json CHECK ( is_json(layout) ) ); +CREATE UNIQUE INDEX label_once_per_ws ON actor.toolbar (ws, label) WHERE ws IS NOT NULL; +CREATE UNIQUE INDEX label_once_per_org ON actor.toolbar (org, label) WHERE org IS NOT NULL; +CREATE UNIQUE INDEX label_once_per_usr ON actor.toolbar (usr, label) WHERE usr IS NOT NULL; +INSERT INTO permission.perm_list ( id, code, description ) VALUES + ( 522, 'IMPORT_AUTHORITY_MARC', oils_i18n_gettext( 522, + 'Allows a user to create new authority records', 'ppl', 'description' )), -- this one was missing + ( 523, 'VIEW_TOOLBAR', oils_i18n_gettext( 523, + 'Allows a user to view and use custom toolbars', 'ppl', 'description' )), + ( 524, 'ADMIN_TOOLBAR', oils_i18n_gettext( 524, + 'Allows a user to create, edit, and delete custom toolbars', 'ppl', 'description' )); -- 2.11.0