Index: pykota/trunk/initscripts/ldap/pykota.schema
===================================================================
--- pykota/trunk/initscripts/ldap/pykota.schema (revision 1223)
+++ pykota/trunk/initscripts/ldap/pykota.schema (revision 1240)
@@ -189,5 +189,5 @@
         DESC 'PyKota Printer'
         MUST ( cn )
-        MAY  ( pykotaPrinterName $ pykotaPricePerPage $ pykotaPricePerJob ) )
+        MAY  ( pykotaPrinterName $ pykotaPricePerPage $ pykotaPricePerJob $ uniqueMember ) )
         
 # pykotaUserPQuota        
Index: pykota/trunk/initscripts/postgresql/pykota-postgresql.sql
===================================================================
--- pykota/trunk/initscripts/postgresql/pykota-postgresql.sql (revision 1203)
+++ pykota/trunk/initscripts/postgresql/pykota-postgresql.sql (revision 1240)
@@ -20,4 +20,7 @@
 --
 -- $Log$
+-- Revision 1.7  2003/12/27 16:49:25  uid67467
+-- Should be ok now.
+--
 -- Revision 1.6  2003/11/23 19:01:36  jalet
 -- Job price added to history
@@ -110,6 +113,6 @@
 CREATE TABLE jobhistory(id SERIAL PRIMARY KEY NOT NULL,
                         jobid TEXT,
-                        userid INT4 REFERENCES users(id),
-                        printerid INT4 REFERENCES printers(id),
+                        userid INT4,
+                        printerid INT4,
                         pagecounter INT4 DEFAULT 0,
                         jobsize INT4,
@@ -120,5 +123,6 @@
                         copies INT4,
                         options TEXT,
-                        jobdate TIMESTAMP DEFAULT now());
+                        jobdate TIMESTAMP DEFAULT now(),
+                        CONSTRAINT checkUserPQuota FOREIGN KEY (userid, printerid) REFERENCES userpquota(userid, printerid));
 CREATE INDEX jobhistory_p_id_ix ON jobhistory (printerid);
 CREATE INDEX jobhistory_pd_id_ix ON jobhistory (printerid, jobdate);
@@ -141,13 +145,20 @@
                            userid INT4 REFERENCES users(id),
                            PRIMARY KEY (groupid, userid));
+                           
+--                         
+-- Create the printer groups relationship
+--
+CREATE TABLE printergroupsmembers(groupid INT4 REFERENCES printers(id),
+                           printerid INT4 REFERENCES printers(id),
+                           PRIMARY KEY (groupid, printerid));
 
 --                        
 -- Set some ACLs                        
 --
-REVOKE ALL ON users, groups, printers, userpquota, grouppquota, groupsmembers, jobhistory FROM public;                        
+REVOKE ALL ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory FROM public;                        
 REVOKE ALL ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq, jobhistory_id_seq FROM public;
 
-GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota, groupsmembers, jobhistory TO pykotaadmin;
+GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory TO pykotaadmin;
 GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq, jobhistory_id_seq TO pykotaadmin;
-GRANT SELECT ON users, groups, printers, userpquota, grouppquota, groupsmembers, jobhistory TO pykotauser;
+GRANT SELECT ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory TO pykotauser;
 
Index: pykota/trunk/initscripts/postgresql/upgrade-to-1.16.sql
===================================================================
--- pykota/trunk/initscripts/postgresql/upgrade-to-1.16.sql (revision 1203)
+++ pykota/trunk/initscripts/postgresql/upgrade-to-1.16.sql (revision 1240)
@@ -20,4 +20,7 @@
 --
 -- $Log$
+-- Revision 1.3  2003/12/27 16:49:25  uid67467
+-- Should be ok now.
+--
 -- Revision 1.2  2003/11/23 19:01:36  jalet
 -- Job price added to history
@@ -48,4 +51,22 @@
 ALTER TABLE jobhistory ADD COLUMN options TEXT;
 
+--
+-- Remove bad integrity rules
+-- and replace them with a new one
+--
+ALTER TABLE jobhistory DROP CONSTRAINT "$1";
+ALTER TABLE jobhistory DROP CONSTRAINT "$2";
+ALTER TABLE jobhistory ADD CONSTRAINT checkUserPQuota FOREIGN KEY (userid, printerid) REFERENCES userpquota (userid, printerid);
+
+-- 
+-- Add new tables
+--
+--                         
+-- Create the printer groups relationship
+--
+CREATE TABLE printergroupsmembers(groupid INT4 REFERENCES printers(id),
+                           printerid INT4 REFERENCES printers(id),
+                           PRIMARY KEY (groupid, printerid));
+
 --                         
 -- Now add some indexes
@@ -56,2 +77,9 @@
 CREATE UNIQUE INDEX grouppquota_up_id_ix ON grouppquota (groupid, printerid);
 
+-- 
+-- And now sets some ACLs
+-- 
+REVOKE ALL ON printergroupsmembers FROM public;                        
+GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON printergroupsmembers TO pykotaadmin;
+GRANT SELECT ON printergroupsmembers TO pykotauser;
+
