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

Revision 1021, 4.3 kB (checked in by jalet, 21 years ago)

Deletion of the second user which is not needed anymore.
Added a debug configuration field in /etc/pykota.conf
All queries can now be sent to the logger in debug mode, this will
greatly help improve performance when time for this will come.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1--
2-- PyKota - Print Quotas for CUPS and LPRng
3--
4-- (c) 2003 Jerome Alet <alet@librelogiciel.com>
5-- This program is free software; you can redistribute it and/or modify
6-- it under the terms of the GNU General Public License as published by
7-- the Free Software Foundation; either version 2 of the License, or
8-- (at your option) any later version.
9--
10-- This program is distributed in the hope that it will be useful,
11-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13-- GNU General Public License for more details.
14--
15-- You should have received a copy of the GNU General Public License
16-- along with this program; if not, write to the Free Software
17-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18--
19-- $Id$
20--
21-- $Log$
22-- Revision 1.2  2003/06/10 16:37:54  jalet
23-- Deletion of the second user which is not needed anymore.
24-- Added a debug configuration field in /etc/pykota.conf
25-- All queries can now be sent to the logger in debug mode, this will
26-- greatly help improve performance when time for this will come.
27--
28-- Revision 1.1  2003/06/05 07:12:31  jalet
29-- Reorganization of directories
30--
31--
32--
33
34--
35-- PyKota Database creation script for PostgreSQL
36--
37-- Launch this as PostgreSQL administrator with \i
38--
39
40
41--
42-- Create the print quota database
43--
44CREATE DATABASE pykota;
45
46--
47-- Create the print quota database users
48--
49CREATE USER pykotaadmin;
50
51--
52-- Now connect to the new database
53--
54\connect pykota
55
56--
57-- Create the users table
58--
59CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL,
60                   username TEXT UNIQUE NOT NULL,
61                   balance FLOAT DEFAULT 0.0,
62                   lifetimepaid FLOAT DEFAULT 0.0,
63                   limitby TEXT DEFAULT 'quota');
64                   
65--
66-- Create the groups table
67--
68CREATE TABLE groups(id SERIAL PRIMARY KEY NOT NULL,
69                    groupname TEXT UNIQUE NOT NULL,
70                    limitby TEXT DEFAULT 'quota');
71                   
72--
73-- Create the printers table
74--
75CREATE TABLE printers(id SERIAL PRIMARY KEY NOT NULL,
76                      printername TEXT UNIQUE NOT NULL,
77                      priceperpage FLOAT DEFAULT 0.0,
78                      priceperjob FLOAT DEFAULT 0.0);
79                   
80--
81-- Create the print quota table for users
82--
83CREATE TABLE userpquota(id SERIAL PRIMARY KEY NOT NULL,
84                        userid INT4 REFERENCES users(id),
85                        printerid INT4 REFERENCES printers(id),
86                        lifepagecounter INT4 DEFAULT 0,
87                        pagecounter INT4 DEFAULT 0,
88                        softlimit INT4,
89                        hardlimit INT4,
90                        datelimit TIMESTAMP);
91                       
92--
93-- Create the job history table
94--
95CREATE TABLE jobhistory(id SERIAL PRIMARY KEY NOT NULL,
96                        jobid TEXT,
97                        userid INT4 REFERENCES users(id),
98                        printerid INT4 REFERENCES printers(id),
99                        pagecounter INT4 DEFAULT 0,
100                        jobsize INT4,
101                        action TEXT,
102                        jobdate TIMESTAMP DEFAULT now());
103                       
104--
105-- Create the print quota table for groups
106--
107CREATE TABLE grouppquota(id SERIAL PRIMARY KEY NOT NULL,
108                         groupid INT4 REFERENCES groups(id),
109                         printerid INT4 REFERENCES printers(id),
110                         softlimit INT4,
111                         hardlimit INT4,
112                         datelimit TIMESTAMP);
113                       
114--                         
115-- Create the groups/members relationship
116--
117CREATE TABLE groupsmembers(groupid INT4 REFERENCES groups(id),
118                           userid INT4 REFERENCES users(id),
119                           PRIMARY KEY (groupid, userid));
120
121--                       
122-- Set some ACLs                       
123--
124REVOKE ALL ON users, groups, printers, userpquota, grouppquota, groupsmembers, jobhistory FROM public;                       
125GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota, groupsmembers, jobhistory TO pykotaadmin;
126GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq, jobhistory_id_seq TO pykotaadmin;
Note: See TracBrowser for help on using the browser.