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

Revision 765, 3.0 kB (checked in by jalet, 21 years ago)

Life time counter for users and groups added.

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