fix constraint syntax
authorJason Etheridge <jason@esilibrary.com>
Tue, 20 Mar 2012 17:03:21 +0000 (13:03 -0400)
committerJason Etheridge <jason@esilibrary.com>
Thu, 22 Mar 2012 14:21:25 +0000 (10:21 -0400)
and add in toolbar related permissions, plus a missing and unrelated perm: IMPORT_AUTHORITY_MARC

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/sql/Pg/005.schema.actors.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql

index 4fead81..a6edeb9 100644 (file)
@@ -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;
index cec8061..0812665 100644 (file)
@@ -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');
 
 
index ae94191..c16f25b 100644 (file)
@@ -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' ));