Mercurial > hg > ltpdarepo
changeset 121:41137a8a2b4c
Extend database schema upgrade test and fix upgrade accordingly.
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Tue, 11 Oct 2011 18:28:28 +0200 |
parents | 9abb62238eb4 |
children | 40fa8f909776 |
files | src/ltpdarepo/tests/test_schema.py src/ltpdarepo/upgrade.py |
diffstat | 2 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ltpdarepo/tests/test_schema.py Tue Oct 11 17:47:52 2011 +0200 +++ b/src/ltpdarepo/tests/test_schema.py Tue Oct 11 18:28:28 2011 +0200 @@ -136,9 +136,10 @@ hosts = sorted([row[0] for row in curs.fetchall()]) self.assertEqual(hosts, ['%', 'localhost']) - # curs.execute("""SELECT Db FROM mysql.db WHERE User = 'u2'""") - # dbs = [row[0] for row in curs.fetchall()] - # self.assertEqual(dbs, ['db1']) + # check privileges + curs.execute("""SELECT Db FROM mysql.db WHERE User = 'u2'""") + dbs = [row[0] for row in curs.fetchall()] + self.assertEqual(dbs, ['db1']) # no explicit privileges on transactions table curs.execute("""SELECT Table_name FROM mysql.tables_priv WHERE User = 'u2'""")
--- a/src/ltpdarepo/upgrade.py Tue Oct 11 17:47:52 2011 +0200 +++ b/src/ltpdarepo/upgrade.py Tue Oct 11 18:28:28 2011 +0200 @@ -63,10 +63,14 @@ curs.execute("""DELETE mysql.db FROM mysql.db, users WHERE User=username AND Host <> '%'""") - # drop privileges granted explicitly on transactions tables + # drop privileges granted explicitly on 'transactions' tables curs.execute("""DELETE mysql.tables_priv FROM mysql.tables_priv, users WHERE User=username AND Table_name='transactions'""") + # drop privileges granted on 'test' database + curs.execute("""DELETE mysql.db FROM mysql.db, users + WHERE User=username AND Db='test'""") + # consolidate users accounts: there is no need to specify user # accounts both for 'localhost' and for '127.0.0.1' hosts. drop # user accounts for '127.0.0.1' @@ -235,6 +239,7 @@ REFERENCES objs(id) ON DELETE CASCADE""" % table) conn.commit() + @register(2.7, 2.8) def upgrade_27_to_28(conn): curs = conn.cursor()