# HG changeset patch # User Daniele Nicolodi # Date 1318350508 -7200 # Node ID 41137a8a2b4c3b051fb526a07bf789d83d6b1d39 # Parent 9abb62238eb48c364540bc5848805d864478d5ad Extend database schema upgrade test and fix upgrade accordingly. diff -r 9abb62238eb4 -r 41137a8a2b4c src/ltpdarepo/tests/test_schema.py --- 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'""") diff -r 9abb62238eb4 -r 41137a8a2b4c src/ltpdarepo/upgrade.py --- 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()