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.4 2003/02/27 08:40:14 jalet |
---|
17 | -- DATETIME is not supported anymore in PostgreSQL 7.3 it seems, but |
---|
18 | -- TIMESTAMP is. |
---|
19 | -- |
---|
20 | -- Revision 1.3 2003/02/26 20:34:22 jalet |
---|
21 | -- Default value for printer page counter set to 0 |
---|
22 | -- |
---|
23 | -- Revision 1.2 2003/02/08 22:12:09 jalet |
---|
24 | -- Life time counter for users and groups added. |
---|
25 | -- |
---|
26 | -- Revision 1.1 2003/02/05 21:28:17 jalet |
---|
27 | -- Initial import into CVS |
---|
28 | -- |
---|
29 | -- |
---|
30 | -- |
---|
31 | |
---|
32 | -- |
---|
33 | -- PyKota Database creation script for PostgreSQL |
---|
34 | -- |
---|
35 | -- Launch this as PostgreSQL administrator with \i |
---|
36 | -- |
---|
37 | |
---|
38 | |
---|
39 | -- |
---|
40 | -- Create the print quota database |
---|
41 | -- |
---|
42 | CREATE DATABASE pykota; |
---|
43 | |
---|
44 | -- |
---|
45 | -- Create the print quota database users |
---|
46 | -- |
---|
47 | CREATE USER pykotauser; |
---|
48 | CREATE USER pykotaadmin; |
---|
49 | |
---|
50 | -- |
---|
51 | -- Now connect to the new database |
---|
52 | -- |
---|
53 | \connect pykota |
---|
54 | |
---|
55 | -- |
---|
56 | -- Create the users table |
---|
57 | -- |
---|
58 | CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL, |
---|
59 | username TEXT UNIQUE NOT NULL); |
---|
60 | |
---|
61 | -- |
---|
62 | -- Create the groups table |
---|
63 | -- |
---|
64 | CREATE TABLE groups(id SERIAL PRIMARY KEY NOT NULL, |
---|
65 | groupname TEXT UNIQUE NOT NULL); |
---|
66 | |
---|
67 | -- |
---|
68 | -- Create the printers table |
---|
69 | -- |
---|
70 | CREATE TABLE printers(id SERIAL PRIMARY KEY NOT NULL, |
---|
71 | printername TEXT UNIQUE NOT NULL, |
---|
72 | lastusername TEXT, |
---|
73 | pagecounter INT4 DEFAULT 0); |
---|
74 | |
---|
75 | -- |
---|
76 | -- Create the print quota table for users |
---|
77 | -- |
---|
78 | CREATE TABLE userpquota(id SERIAL PRIMARY KEY NOT NULL, |
---|
79 | userid INT4 REFERENCES users(id), |
---|
80 | printerid INT4 REFERENCES printers(id), |
---|
81 | lifepagecounter INT4 DEFAULT 0, |
---|
82 | pagecounter INT4 DEFAULT 0, |
---|
83 | softlimit INT4, |
---|
84 | hardlimit INT4, |
---|
85 | datelimit TIMESTAMP); |
---|
86 | |
---|
87 | -- |
---|
88 | -- Create the print quota table for groups |
---|
89 | -- |
---|
90 | CREATE TABLE grouppquota(id SERIAL PRIMARY KEY NOT NULL, |
---|
91 | groupid INT4 REFERENCES groups(id), |
---|
92 | printerid INT4 REFERENCES printers(id), |
---|
93 | lifepagecounter INT4 DEFAULT 0, |
---|
94 | pagecounter INT4 DEFAULT 0, |
---|
95 | softlimit INT4, |
---|
96 | hardlimit INT4, |
---|
97 | datelimit TIMESTAMP); |
---|
98 | |
---|
99 | -- |
---|
100 | -- Set some ACLs |
---|
101 | -- |
---|
102 | REVOKE ALL ON users, groups, printers, userpquota, grouppquota FROM public; |
---|
103 | GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota TO pykotaadmin; |
---|
104 | GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq TO pykotaadmin; |
---|
105 | GRANT SELECT, UPDATE ON printers, userpquota, grouppquota TO pykotauser; |
---|
106 | GRANT SELECT ON users, groups TO pykotauser; |
---|