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

Revision 812, 3.2 kB (checked in by jalet, 21 years ago)

DATETIME is not supported anymore in PostgreSQL 7.3 it seems, but
TIMESTAMP is.

  • 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$
[812]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--
[811]20-- Revision 1.3  2003/02/26 20:34:22  jalet
21-- Default value for printer page counter set to 0
22--
[765]23-- Revision 1.2  2003/02/08 22:12:09  jalet
24-- Life time counter for users and groups added.
25--
[695]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--
42CREATE DATABASE pykota;
43
44--
45-- Create the print quota database users
46--
47CREATE USER pykotauser;
48CREATE USER pykotaadmin;
49
50--
51-- Now connect to the new database
52--
53\connect pykota
54
55--
56-- Create the users table
57--
58CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL,
59                   username TEXT UNIQUE NOT NULL);
60                   
61--
62-- Create the groups table
63--
64CREATE TABLE groups(id SERIAL PRIMARY KEY NOT NULL,
65                    groupname TEXT UNIQUE NOT NULL);
66                   
67--
68-- Create the printers table
69--
70CREATE TABLE printers(id SERIAL PRIMARY KEY NOT NULL,
71                      printername TEXT UNIQUE NOT NULL,
72                      lastusername TEXT,
[811]73                      pagecounter INT4 DEFAULT 0);
[695]74                   
75--
76-- Create the print quota table for users
77--
78CREATE TABLE userpquota(id SERIAL PRIMARY KEY NOT NULL,
79                        userid INT4 REFERENCES users(id),
80                        printerid INT4 REFERENCES printers(id),
[765]81                        lifepagecounter INT4 DEFAULT 0,
[695]82                        pagecounter INT4 DEFAULT 0,
83                        softlimit INT4,
84                        hardlimit INT4,
[812]85                        datelimit TIMESTAMP);
[695]86                       
87--
88-- Create the print quota table for groups
89--
90CREATE TABLE grouppquota(id SERIAL PRIMARY KEY NOT NULL,
91                         groupid INT4 REFERENCES groups(id),
92                         printerid INT4 REFERENCES printers(id),
[765]93                         lifepagecounter INT4 DEFAULT 0,
[695]94                         pagecounter INT4 DEFAULT 0,
95                         softlimit INT4,
96                         hardlimit INT4,
[812]97                         datelimit TIMESTAMP);
[695]98                       
99--                       
100-- Set some ACLs                       
101--
102REVOKE ALL ON users, groups, printers, userpquota, grouppquota FROM public;                       
103GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota TO pykotaadmin;
104GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq TO pykotaadmin;
105GRANT SELECT, UPDATE ON printers, userpquota, grouppquota TO pykotauser;
106GRANT SELECT ON users, groups TO pykotauser;
Note: See TracBrowser for help on using the browser.