root / pykota / trunk / initscripts / pykota-postgresql.sql @ 849

Revision 849, 3.5 kB (checked in by jalet, 21 years ago)

Initial support for groups added.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1--
2-- PyKota - Print Quotas for CUPS
3--
4-- (c) 2003 Jerome Alet <alet@librelogiciel.com>
5-- You're welcome to redistribute this software under the
6-- terms of the GNU General Public Licence version 2.0
7-- or, at your option, any higher version.
8--
9-- You can read the complete GNU GPL in the file COPYING
10-- which should come along with this software, or visit
11-- the Free Software Foundation's WEB site http://www.fsf.org
12--
13-- $Id$
14--
15-- $Log$
16-- Revision 1.5  2003/03/12 19:06:08  jalet
17-- Initial support for groups added.
18--
19-- Revision 1.4  2003/02/27 08:40:14  jalet
20-- DATETIME is not supported anymore in PostgreSQL 7.3 it seems, but
21-- TIMESTAMP is.
22--
23-- Revision 1.3  2003/02/26 20:34:22  jalet
24-- Default value for printer page counter set to 0
25--
26-- Revision 1.2  2003/02/08 22:12:09  jalet
27-- Life time counter for users and groups added.
28--
29-- Revision 1.1  2003/02/05 21:28:17  jalet
30-- Initial import into CVS
31--
32--
33--
34
35--
36-- PyKota Database creation script for PostgreSQL
37--
38-- Launch this as PostgreSQL administrator with \i
39--
40
41
42--
43-- Create the print quota database
44--
45CREATE DATABASE pykota;
46
47--
48-- Create the print quota database users
49--
50CREATE USER pykotauser;
51CREATE USER pykotaadmin;
52
53--
54-- Now connect to the new database
55--
56\connect pykota
57
58--
59-- Create the users table
60--
61CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL,
62                   username TEXT UNIQUE NOT NULL);
63                   
64--
65-- Create the groups table
66--
67CREATE TABLE groups(id SERIAL PRIMARY KEY NOT NULL,
68                    groupname TEXT UNIQUE NOT NULL);
69                   
70--
71-- Create the printers table
72--
73CREATE TABLE printers(id SERIAL PRIMARY KEY NOT NULL,
74                      printername TEXT UNIQUE NOT NULL,
75                      lastusername TEXT,
76                      pagecounter INT4 DEFAULT 0);
77                   
78--
79-- Create the print quota table for users
80--
81CREATE TABLE userpquota(id SERIAL PRIMARY KEY NOT NULL,
82                        userid INT4 REFERENCES users(id),
83                        printerid INT4 REFERENCES printers(id),
84                        lifepagecounter INT4 DEFAULT 0,
85                        pagecounter INT4 DEFAULT 0,
86                        softlimit INT4,
87                        hardlimit INT4,
88                        datelimit TIMESTAMP);
89                       
90--
91-- Create the print quota table for groups
92--
93CREATE TABLE grouppquota(id SERIAL PRIMARY KEY NOT NULL,
94                         groupid INT4 REFERENCES groups(id),
95                         printerid INT4 REFERENCES printers(id),
96                         softlimit INT4,
97                         hardlimit INT4,
98                         datelimit TIMESTAMP);
99                       
100--                         
101-- Create the groups/members relationship
102--
103CREATE TABLE groupsmembers(groupid INT4 REFERENCES groups(id),
104                           userid INT4 REFERENCES users(id),
105                           PRIMARY KEY (groupid, userid));
106
107--                       
108-- Set some ACLs                       
109--
110REVOKE ALL ON users, groups, printers, userpquota, grouppquota, groupsmembers FROM public;                       
111GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota, groupsmembers TO pykotaadmin;
112GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq TO pykotaadmin;
113GRANT SELECT, UPDATE ON printers, userpquota, grouppquota TO pykotauser;
114GRANT SELECT ON users, groups, groupsmembers TO pykotauser;
Note: See TracBrowser for help on using the browser.