Changeset 3413 for pykota/trunk/initscripts/postgresql
- Timestamp:
- 09/27/08 22:02:37 (16 years ago)
- Location:
- pykota/trunk/initscripts/postgresql
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/initscripts/postgresql/pykota-postgresql.sql
r3279 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 35 35 -- Create the print quota database users 36 36 -- NOTE: Change the password values to the passwords you would like. 37 -- 37 -- 38 38 CREATE USER pykotauser WITH UNENCRYPTED PASSWORD 'readonlypw' NOCREATEDB NOCREATEUSER; 39 39 CREATE USER pykotaadmin WITH UNENCRYPTED PASSWORD 'readwritepw' NOCREATEDB NOCREATEUSER; 40 40 41 -- 41 -- 42 42 -- Now connect to the new database 43 -- 43 -- 44 44 \connect pykota 45 45 … … 49 49 CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL, 50 50 username TEXT UNIQUE NOT NULL, 51 email TEXT, 51 email TEXT, 52 52 balance FLOAT DEFAULT 0.0, 53 53 lifetimepaid FLOAT DEFAULT 0.0, … … 55 55 description TEXT, 56 56 overcharge FLOAT NOT NULL DEFAULT 1.0); 57 57 58 58 -- 59 59 -- Create the groups table … … 63 63 description TEXT, 64 64 limitby TEXT DEFAULT 'quota'); 65 65 66 66 -- 67 67 -- Create the printers table … … 74 74 passthrough BOOLEAN DEFAULT FALSE, 75 75 maxjobsize INT4); 76 76 77 77 -- 78 78 -- Create the print quota table for users … … 87 87 datelimit TIMESTAMP, 88 88 maxjobsize INT4, 89 warncount INT4 DEFAULT 0); 89 warncount INT4 DEFAULT 0); 90 90 CREATE INDEX userpquota_u_id_ix ON userpquota (userid); 91 91 CREATE INDEX userpquota_p_id_ix ON userpquota (printerid); 92 92 CREATE UNIQUE INDEX userpquota_up_id_ix ON userpquota (userid, printerid); 93 93 94 94 -- 95 95 -- Create the job history table … … 120 120 CREATE INDEX jobhistory_pd_id_ix ON jobhistory (printerid, jobdate); 121 121 CREATE INDEX jobhistory_hostname_ix ON jobhistory (hostname); 122 122 123 123 -- 124 124 -- Create the print quota table for groups … … 134 134 CREATE INDEX grouppquota_p_id_ix ON grouppquota (printerid); 135 135 CREATE UNIQUE INDEX grouppquota_up_id_ix ON grouppquota (groupid, printerid); 136 137 -- 136 137 -- 138 138 -- Create the groups/members relationship 139 139 -- … … 141 141 userid INT4 REFERENCES users(id), 142 142 PRIMARY KEY (groupid, userid)); 143 144 -- 143 144 -- 145 145 -- Create the printer groups relationship 146 146 -- … … 150 150 -- 151 151 -- Create the table for payments 152 -- 152 -- 153 153 CREATE TABLE payments (id SERIAL PRIMARY KEY NOT NULL, 154 154 userid INT4 REFERENCES users(id), … … 158 158 CREATE INDEX payments_date_ix ON payments (date); 159 159 160 -- 160 -- 161 161 -- Create the table for coefficients wrt paper sizes and the like 162 162 -- 163 CREATE TABLE coefficients (id SERIAL PRIMARY KEY NOT NULL, 164 printerid INTEGER NOT NULL REFERENCES printers(id), 165 label TEXT NOT NULL, 166 coefficient FLOAT DEFAULT 1.0, 163 CREATE TABLE coefficients (id SERIAL PRIMARY KEY NOT NULL, 164 printerid INTEGER NOT NULL REFERENCES printers(id), 165 label TEXT NOT NULL, 166 coefficient FLOAT DEFAULT 1.0, 167 167 CONSTRAINT coeffconstraint UNIQUE (printerid, label)); 168 168 169 -- 169 -- 170 170 -- Create the table for the billing codes 171 171 -- … … 176 176 pagecounter INT4 DEFAULT 0); 177 177 178 -- 179 -- Set some ACLs 178 -- 179 -- Set some ACLs 180 180 -- 181 181 REVOKE ALL ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory, payments, coefficients, billingcodes FROM public; -
pykota/trunk/initscripts/postgresql/README.postgresql
r3279 r3413 31 31 - edit the pykota-postgresql.sql file and modify the passwords on 32 32 the 'CREATE USER' lines. 33 33 34 34 - Launch the psql frontend and connect to the 35 35 database template1 as a PostgreSQL administrator 36 36 (i.e. the postgres user) : 37 37 38 38 as user 'root' : 39 39 40 40 # su - postgres 41 42 you're now user 'postgres', then continue with : 43 41 42 you're now user 'postgres', then continue with : 43 44 44 $ psql -f pykota-postgresql.sql template1 45 46 or depending on your settings you may prefer : 47 45 46 or depending on your settings you may prefer : 47 48 48 $ psql -h localhost -U postgres -f pykota-postgresql.sql template1 49 50 - If no error message appears, your PostgreSQL PyKota storage 49 50 - If no error message appears, your PostgreSQL PyKota storage 51 51 is now ready for use. NB : a lot of NOTICE messages might appear, 52 52 this is perfectly normal. 53 53 54 54 - In ~pykota/pykota.conf, ensure that the following lines 55 55 are present and unique inside the [global] section : 56 56 57 57 storagebackend : pgstorage 58 58 storageserver : localhost … … 60 60 storageuser : pykotauser 61 61 storageuserpw : readonlypw 62 62 63 63 NB : replace 'readonlypw' with the password you chose 64 64 for user 'pykotauser' when you modified pykota-postgresql.sql 65 65 66 66 - In ~pykota/pykotadmin.conf ensure that the following lines 67 67 are present and unique inside the [global] section : 68 68 69 69 storageadmin : pykotaadmin 70 70 storageadminpw : readwritepw 71 71 72 72 NB : replace 'readwritepw' with the password you chose 73 73 for user 'pykotaadmin' when you modified pykota-postgresql.sql 74 75 - IMPORTANT : if your database is not located on the print server, 76 replace 'localhost' in the lines above with your database server's 74 75 - IMPORTANT : if your database is not located on the print server, 76 replace 'localhost' in the lines above with your database server's 77 77 hostname or IP address. If your database server doesn't listen on 78 78 its standard port, add the port number at the end of the hostname 79 79 with a colon to separate the hostname from the port. 80 80 See pykota/conf/pykota.conf.sample for examples. 81 81 82 82 ============================================================ 83 83 … … 89 89 Some scripts to upgrade old PyKota databases to the new 90 90 database schema are included. You may have to run all 91 of them or only some of them, depending on your 91 of them or only some of them, depending on your 92 92 version of PyKota. Usually running them several times, for 93 93 example if you used several different development versions 94 94 of PyKota, won't do any harm. 95 95 96 96 If you're connected as user 'root', you have to be user 'postgres' 97 97 instead : 98 98 99 99 # su - postgres 100 100 101 101 You're now user 'postgres', then continue the upgrade by following 102 102 the instructions below, depending on the version you actually use : 103 103 104 104 * An SQL script to upgrade a 1.22 PyKota Storage DataBase to 105 105 1.23 is included. Launch it this way on the Quota Storage Server : 106 106 107 107 $ psql -U postgres pykota 108 108 pykota=# \i upgrade-to-1.23.sql 109 109 pykota=# \q 110 110 $ 111 111 112 112 This script adds many fields to existing tables, and a table to 113 113 manage billing codes. 114 114 115 115 * An SQL script to upgrade a 1.20 PyKota Storage DataBase to 116 116 1.21 is included. Launch it this way on the Quota Storage Server : 117 117 118 118 $ psql -U postgres pykota 119 119 pykota=# \i upgrade-to-1.21.sql 120 120 pykota=# \q 121 121 $ 122 122 123 123 This script adds many fields to existing tables, and also adds 124 124 some tables in indexes. 125 125 126 126 * An SQL script to upgrade a 1.18 PyKota Storage DataBase to 127 127 1.19 is included. Launch it this way on the Quota Storage Server : 128 128 129 129 $ psql -U postgres pykota 130 130 pykota=# \i upgrade-to-1.19.sql 131 131 pykota=# \q 132 132 $ 133 133 134 134 This script adds a field to the print job history. The field that 135 135 is added is : hostname 136 136 137 137 * An SQL script to upgrade a pre-1.16 PyKota Storage DataBase to 138 138 1.16 is included. Launch it this way on the Quota Storage Server : 139 139 140 140 $ psql -U postgres pykota 141 141 pykota=# \i upgrade-to-1.16.sql 142 142 pykota=# \q 143 143 $ 144 144 145 145 This script adds some fields to the print job history, so that 146 146 more complete information will be known. The fields that 147 are added are : jobprice, filename, title, copies and print 147 are added are : jobprice, filename, title, copies and print 148 148 command options. Also some indexes are created to speed things up. 149 150 What is below is for historical reasons only, real people don't use 149 150 What is below is for historical reasons only, real people don't use 151 151 such old beasts, and YOU SHOULDN'T EITHER ! 152 152 153 153 * An SQL script to upgrade a pre-1.14 PyKota Storage DataBase to 154 154 1.14 is included. Launch it this way on the Quota Storage Server : 155 155 156 156 $ psql -U postgres pykota 157 157 pykota=# \i upgrade-to-1.14.sql 158 158 pykota=# \q 159 159 $ 160 161 This script adds an "email" field for each user. This field, if not 160 161 This script adds an "email" field for each user. This field, if not 162 162 NULL, is used as the email address of the user when sending warning 163 163 messages in case he is over quota. 164 165 * An sql script to upgrade a pre-1.01 PyKota Quota Storage DataBase to 166 1.01 is still included for historical reasons. PLEASE DON'T USE IT ! 167 168 * If you are already running an old version of PyKota (<1.03) and 169 want to upgrade to 1.03, YOU HAVE TO RUN the 170 upgrade-from-before-1.03.py shell script. NOT LAUNCHING THIS SCRIPT 171 WILL CAUSE PYKOTA TO STOP WORKING ! PLEASE NEVER RUN THIS SCRIPT IF 172 YOUR EXISTING VERSION OF PYKOTA IS ALREADY 1.03 OR HIGHER. 164 165 * An sql script to upgrade a pre-1.01 PyKota Quota Storage DataBase to 166 1.01 is still included for historical reasons. PLEASE DON'T USE IT ! 167 168 * If you are already running an old version of PyKota (<1.03) and 169 want to upgrade to 1.03, YOU HAVE TO RUN the 170 upgrade-from-before-1.03.py shell script. NOT LAUNCHING THIS SCRIPT 171 WILL CAUSE PYKOTA TO STOP WORKING ! PLEASE NEVER RUN THIS SCRIPT IF 172 YOUR EXISTING VERSION OF PYKOTA IS ALREADY 1.03 OR HIGHER. -
pykota/trunk/initscripts/postgresql/upgrade-from-before-1.03.py
r3259 r3413 8 8 # the Free Software Foundation, either version 3 of the License, or 9 9 # (at your option) any later version. 10 # 10 # 11 11 # This program is distributed in the hope that it will be useful, 12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 # GNU General Public License for more details. 15 # 15 # 16 16 # You should have received a copy of the GNU General Public License 17 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. … … 26 26 try : 27 27 import pg 28 except ImportError : 28 except ImportError : 29 29 sys.stderr.write("The PyGreSQL Python module doesn't seem to be available. ABORTED.\n") 30 30 sys.exit(-1) … … 32 32 def dump_old_database() : 33 33 """Dumps the existing PyKota database to a file, to avoir loosing data. 34 34 35 35 Returns 1 if dump is successfull, 0 if it isn't. 36 """ 36 """ 37 37 pipeinput = os.popen("pg_dump -C -D -N -U postgres -f pykota-dump.sql pykota") 38 38 dummy = pipeinput.read() … … 44 44 dummy = pipeinput.read() 45 45 return (pipeinput.close() is None) or 0 46 46 47 47 def restore_original_database() : 48 48 """Creates the empty database.""" … … 50 50 dummy = pipeinput.read() 51 51 return (pipeinput.close() is None) or 0 52 52 53 53 def open_database(dbname="pykota") : 54 54 """Returns the database object or None if we can't connect to it.""" 55 55 try : 56 56 pykotadb = pg.connect(host="localhost", port=5432, dbname=dbname, user="postgres") 57 except pg.error, msg : 57 except pg.error, msg : 58 58 sys.stderr.write("%s\n" % msg) 59 59 sys.stderr.write("Unable to connect to the local PostgreSQL server.\nPlease modify the open_database() method in %s\nto connect to the correct PostgreSQL server\nand relaunch the script.\n" % sys.argv[0]) 60 return 61 else : 60 return 61 else : 62 62 return pykotadb 63 64 63 64 65 65 def doQuote(field) : 66 66 """Quotes a field for use as a string in SQL queries.""" 67 67 if type(field) == type(0) : # TODO : do something safer 68 68 typ = "decimal" 69 else : 69 else : 70 70 typ = "text" 71 71 return pg._quote(field, typ) 72 72 73 73 def main() : 74 74 """Does the work.""" 75 75 76 76 # First we make a dump of the old database 77 77 print "Dumping old database for safety...", … … 80 80 return -1 81 81 print "Done." 82 83 # Second we try to connect to it 84 print "Extracting datas from old database...", 82 83 # Second we try to connect to it 84 print "Extracting datas from old database...", 85 85 db = open_database() 86 86 if db is None : 87 87 sys.stderr.write("Impossible to connect to old PyKota database. ABORTED.\nAre you sure you are upgrading an existing installation ?\n") 88 88 return -1 89 89 90 90 # Third we extract datas 91 91 oldprinters = db.query("SELECT * FROM printers ORDER BY id;") 92 92 oldusers = db.query("SELECT * FROM users ORDER BY id;") 93 93 oldquotas = db.query("SELECT * FROM userpquota ORDER BY printerid, userid;") 94 94 95 95 # Fourth close the database 96 96 db.close() 97 97 print "Done." 98 98 99 99 # Fifth we delete the old database ! 100 100 answer = raw_input("The old database will be deleted for the upgrade to take place.\nAre you sure you want to continue (y/N) ? ") … … 112 112 db.close() 113 113 return -1 114 else : 114 else : 115 115 db.close() 116 116 117 117 # Sixth we create the new database 118 118 print "Creating the new database...", … … 121 121 return -1 122 122 print "Done." 123 123 124 124 # Seventh we restore old data 125 125 print "Restoring old datas..." … … 131 131 sys.stderr.write("Shit ! A double-error occured !!!\nPlease report problem to your database administrator.\n") 132 132 sys.stderr.write("And file a bug report to alet@librelogiciel.com\n") 133 else : 133 else : 134 134 print "Done." 135 135 return -1 136 db.query("BEGIN;") 136 db.query("BEGIN;") 137 137 try : 138 138 newprinters = {} … … 141 141 newid = db.query("SELECT id FROM printers WHERE printername='%s';" % oldprinter["printername"]).dictresult()[0]["id"] 142 142 newprinters[oldprinter["id"]] = newid 143 newusers = {} 144 for olduser in oldusers.dictresult() : 143 newusers = {} 144 for olduser in oldusers.dictresult() : 145 145 db.query("INSERT INTO users (username) VALUES (%s);" % doQuote(olduser["username"])) 146 146 newid = db.query("SELECT id FROM users WHERE username='%s';" % olduser["username"]).dictresult()[0]["id"] 147 147 newusers[olduser["id"]] = newid 148 for oldquota in oldquotas.dictresult() : 149 db.query("INSERT INTO userpquota (userid, printerid, pagecounter, lifepagecounter, softlimit, hardlimit, datelimit) VALUES (%s, %s, %s, %s, %s, %s, %s);" % 148 for oldquota in oldquotas.dictresult() : 149 db.query("INSERT INTO userpquota (userid, printerid, pagecounter, lifepagecounter, softlimit, hardlimit, datelimit) VALUES (%s, %s, %s, %s, %s, %s, %s);" % 150 150 (doQuote(newusers[oldquota["userid"]]) , doQuote(newprinters[oldquota["printerid"]]), doQuote(oldquota["pagecounter"]), doQuote(oldquota["lifepagecounter"]), doQuote(oldquota["softlimit"]), doQuote(oldquota["hardlimit"]), doQuote(oldquota["datelimit"]))) 151 except pg.error, msg : 151 except pg.error, msg : 152 152 sys.stderr.write("ERROR : %s\nABORTED.\n" % msg) 153 153 db.query("ROLLBACK;") 154 db.close() 154 db.close() 155 155 return -1 156 except : 156 except : 157 157 sys.stderr.write("Unknown error ! ABORTED.\n") 158 158 db.query("ROLLBACK;") 159 db.close() 159 db.close() 160 160 return -1 161 else : 161 else : 162 162 db.query("COMMIT;") 163 163 db.close() … … 165 165 print "NB : Last job on each printer was lost. This is normal !" 166 166 return 0 167 167 168 168 if __name__ == "__main__" : 169 169 sys.exit(main()) -
pykota/trunk/initscripts/postgresql/upgrade-to-1.14.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 19 19 -- 20 20 -- 21 22 -- 21 22 -- 23 23 -- WARNING : YOU NEED A RECENT VERSION OF POSTGRESQL FOR THE ALTER COLUMN STATEMENT TO WORK ! 24 24 -- 25 25 26 -- 26 -- 27 27 -- Modify the old database schema 28 28 -- -
pykota/trunk/initscripts/postgresql/upgrade-to-1.16.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. 17 -- 17 -- 18 18 -- $Id$ 19 19 -- … … 22 22 -- This script has to be used if you already 23 23 -- have a pre-1.16 version of PyKota to upgrade 24 -- your database schema. 24 -- your database schema. 25 25 -- 26 26 -- YOU DON'T NEED TO USE IT IF YOU'VE JUST INSTALLED PYKOTA 27 27 -- 28 29 -- 28 29 -- 30 30 -- WARNING : YOU NEED A RECENT VERSION OF POSTGRESQL FOR THE ALTER COLUMN STATEMENT TO WORK ! 31 31 -- 32 32 33 -- 33 -- 34 34 -- Modify the old database schema 35 35 -- … … 48 48 ALTER TABLE jobhistory ADD CONSTRAINT checkUserPQuota FOREIGN KEY (userid, printerid) REFERENCES userpquota (userid, printerid); 49 49 50 -- 50 -- 51 51 -- Add new tables 52 52 -- 53 -- 53 -- 54 54 -- Create the printer groups relationship 55 55 -- … … 58 58 PRIMARY KEY (groupid, printerid)); 59 59 60 -- 60 -- 61 61 -- Now add some indexes 62 62 -- … … 66 66 CREATE UNIQUE INDEX grouppquota_up_id_ix ON grouppquota (groupid, printerid); 67 67 68 -- 68 -- 69 69 -- And now sets some ACLs 70 -- 71 REVOKE ALL ON printergroupsmembers FROM public; 70 -- 71 REVOKE ALL ON printergroupsmembers FROM public; 72 72 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON printergroupsmembers TO pykotaadmin; 73 73 GRANT SELECT ON printergroupsmembers TO pykotauser; -
pykota/trunk/initscripts/postgresql/upgrade-to-1.19.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 22 22 -- This script has to be used if you already 23 23 -- have a pre-1.19 version of PyKota to upgrade 24 -- your database schema. 24 -- your database schema. 25 25 -- 26 26 -- YOU DON'T NEED TO USE IT IF YOU'VE JUST INSTALLED PYKOTA 27 27 -- 28 29 -- 28 29 -- 30 30 -- WARNING : YOU NEED A RECENT VERSION OF POSTGRESQL FOR THE ALTER COLUMN STATEMENT TO WORK ! 31 31 -- 32 32 33 -- 33 -- 34 34 -- Modify the old database schema 35 35 -- … … 45 45 CREATE INDEX payments_date_ix ON payments (date); 46 46 47 REVOKE ALL ON payments FROM public; 47 REVOKE ALL ON payments FROM public; 48 48 REVOKE ALL ON payments_id_seq FROM public; 49 49 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON payments TO pykotaadmin; -
pykota/trunk/initscripts/postgresql/upgrade-to-1.21.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 22 22 -- This script has to be used if you already 23 23 -- have a pre-1.21 version of PyKota to upgrade 24 -- your database schema. 24 -- your database schema. 25 25 -- 26 26 -- YOU DON'T NEED TO USE IT IF YOU'VE JUST INSTALLED PYKOTA 27 27 -- 28 29 -- 28 29 -- 30 30 -- Modify the old database schema 31 31 -- … … 51 51 CREATE INDEX jobhistory_u_id_ix ON jobhistory (userid); 52 52 53 -- 53 -- 54 54 -- Create the table for coefficients wrt paper sizes and the like 55 55 -- 56 CREATE TABLE coefficients (id SERIAL PRIMARY KEY NOT NULL, 57 printerid INTEGER NOT NULL REFERENCES printers(id), 58 label TEXT NOT NULL, 59 coefficient FLOAT DEFAULT 1.0, 56 CREATE TABLE coefficients (id SERIAL PRIMARY KEY NOT NULL, 57 printerid INTEGER NOT NULL REFERENCES printers(id), 58 label TEXT NOT NULL, 59 coefficient FLOAT DEFAULT 1.0, 60 60 CONSTRAINT coeffconstraint UNIQUE (printerid, label)); 61 62 REVOKE ALL ON coefficients FROM public; 61 62 REVOKE ALL ON coefficients FROM public; 63 63 REVOKE ALL ON coefficients_id_seq FROM public; 64 64 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON coefficients TO pykotaadmin; -
pykota/trunk/initscripts/postgresql/upgrade-to-1.23.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 22 22 -- This script has to be used if you already 23 23 -- have a pre-1.23alpha30 version of PyKota to upgrade 24 -- your database schema. 24 -- your database schema. 25 25 -- 26 26 -- YOU DON'T NEED TO USE IT IF YOU'VE JUST INSTALLED PYKOTA 27 27 -- 28 29 -- 28 29 -- 30 30 -- Modify the old database schema 31 31 -- … … 49 49 UPDATE printers SET passthrough=FALSE; 50 50 51 -- 51 -- 52 52 -- Create the table for the billing codes 53 53 -- … … 59 59 ALTER TABLE billingcodes RENAME COLUMN label TO billingcode; 60 60 61 REVOKE ALL ON billingcodes FROM public; 61 REVOKE ALL ON billingcodes FROM public; 62 62 REVOKE ALL ON billingcodes_id_seq FROM public; 63 63 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON billingcodes TO pykotaadmin; -
pykota/trunk/initscripts/postgresql/VERYOLDpykota-upgrade-postgresql.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 26 26 -- the normal script instead. 27 27 -- 28 29 -- 28 29 -- 30 30 -- WARNING : YOU NEED A RECENT VERSION OF POSTGRESQL FOR THE DROP COLUMN STATEMENT TO WORK ! 31 31 -- 32 32 33 -- 33 -- 34 34 -- Modify the old database schema 35 35 -- … … 37 37 ALTER TABLE grouppquota DROP COLUMN pagecounter; 38 38 39 -- 39 -- 40 40 -- Create the groups/members relationship 41 41 -- … … 43 43 userid INT4 REFERENCES users(id), 44 44 PRIMARY KEY (groupid, userid)); 45 46 -- 47 -- Set some ACLs 45 48 46 -- 49 REVOKE ALL ON groupsmembers FROM public; 47 -- Set some ACLs 48 -- 49 REVOKE ALL ON groupsmembers FROM public; 50 50 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON groupsmembers TO pykotaadmin;