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

Revision 811, 3.1 kB (checked in by jalet, 21 years ago)

Default value for printer page counter set to 0

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