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

Revision 873, 4.0 kB (checked in by jalet, 21 years ago)

GPL paragraphs were incorrectly (from memory) copied into the sources.
Two README files were added.
Upgrade script for PostgreSQL pre 1.01 schema was added.

  • 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-- 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.6  2003/03/29 13:45:27  jalet
23-- GPL paragraphs were incorrectly (from memory) copied into the sources.
24-- Two README files were added.
25-- Upgrade script for PostgreSQL pre 1.01 schema was added.
26--
27-- Revision 1.5  2003/03/12 19:06:08  jalet
28-- Initial support for groups added.
29--
30-- Revision 1.4  2003/02/27 08:40:14  jalet
31-- DATETIME is not supported anymore in PostgreSQL 7.3 it seems, but
32-- TIMESTAMP is.
33--
34-- Revision 1.3  2003/02/26 20:34:22  jalet
35-- Default value for printer page counter set to 0
36--
37-- Revision 1.2  2003/02/08 22:12:09  jalet
38-- Life time counter for users and groups added.
39--
40-- Revision 1.1  2003/02/05 21:28:17  jalet
41-- Initial import into CVS
42--
43--
44--
45
46--
47-- PyKota Database creation script for PostgreSQL
48--
49-- Launch this as PostgreSQL administrator with \i
50--
51
52
53--
54-- Create the print quota database
55--
56CREATE DATABASE pykota;
57
58--
59-- Create the print quota database users
60--
61CREATE USER pykotauser;
62CREATE USER pykotaadmin;
63
64--
65-- Now connect to the new database
66--
67\connect pykota
68
69--
70-- Create the users table
71--
72CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL,
73                   username TEXT UNIQUE NOT NULL);
74                   
75--
76-- Create the groups table
77--
78CREATE TABLE groups(id SERIAL PRIMARY KEY NOT NULL,
79                    groupname TEXT UNIQUE NOT NULL);
80                   
81--
82-- Create the printers table
83--
84CREATE TABLE printers(id SERIAL PRIMARY KEY NOT NULL,
85                      printername TEXT UNIQUE NOT NULL,
86                      lastusername TEXT,
87                      pagecounter INT4 DEFAULT 0);
88                   
89--
90-- Create the print quota table for users
91--
92CREATE TABLE userpquota(id SERIAL PRIMARY KEY NOT NULL,
93                        userid INT4 REFERENCES users(id),
94                        printerid INT4 REFERENCES printers(id),
95                        lifepagecounter INT4 DEFAULT 0,
96                        pagecounter INT4 DEFAULT 0,
97                        softlimit INT4,
98                        hardlimit INT4,
99                        datelimit TIMESTAMP);
100                       
101--
102-- Create the print quota table for groups
103--
104CREATE TABLE grouppquota(id SERIAL PRIMARY KEY NOT NULL,
105                         groupid INT4 REFERENCES groups(id),
106                         printerid INT4 REFERENCES printers(id),
107                         softlimit INT4,
108                         hardlimit INT4,
109                         datelimit TIMESTAMP);
110                       
111--                         
112-- Create the groups/members relationship
113--
114CREATE TABLE groupsmembers(groupid INT4 REFERENCES groups(id),
115                           userid INT4 REFERENCES users(id),
116                           PRIMARY KEY (groupid, userid));
117
118--                       
119-- Set some ACLs                       
120--
121REVOKE ALL ON users, groups, printers, userpquota, grouppquota, groupsmembers FROM public;                       
122GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota, groupsmembers TO pykotaadmin;
123GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq TO pykotaadmin;
124GRANT SELECT, UPDATE ON printers, userpquota, grouppquota TO pykotauser;
125GRANT SELECT ON users, groups, groupsmembers TO pykotauser;
Note: See TracBrowser for help on using the browser.