# HG changeset patch # User Daniele Nicolodi # Date 1357321672 -3600 # Node ID 5e11cd66721d5c893ae06a2b33e77ec47aeaa3a4 # Parent 739af4852be1c4bf4e0c82bb7d0db201a0db8890 Convert all tables to InnoDB storage. Bump schema revision to 32. diff -r 739af4852be1 -r 5e11cd66721d src/ltpdarepo/__init__.py --- a/src/ltpdarepo/__init__.py Fri Jan 04 18:47:43 2013 +0100 +++ b/src/ltpdarepo/__init__.py Fri Jan 04 18:47:52 2013 +0100 @@ -25,7 +25,7 @@ from .views.users import module as users -SCHEMA = 31 +SCHEMA = 32 # customize mysql types conversion from and to DATETIME fields to diff -r 739af4852be1 -r 5e11cd66721d src/ltpdarepo/install.py --- a/src/ltpdarepo/install.py Fri Jan 04 18:47:43 2013 +0100 +++ b/src/ltpdarepo/install.py Fri Jan 04 18:47:52 2013 +0100 @@ -47,7 +47,7 @@ `version` int(11) DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `database` (`db_name`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8""") + ) ENGINE=InnoDB DEFAULT CHARSET=utf8""") curs.execute("""CREATE TABLE `users` ( `id` int NOT NULL AUTO_INCREMENT, @@ -59,7 +59,7 @@ `telephone` varchar(50) NOT NULL, `is_admin` tinyint(1) NOT NULL, PRIMARY KEY (`id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8""") + ) ENGINE=InnoDB DEFAULT CHARSET=utf8""") curs.execute("""CREATE TABLE `queries` ( `id` int NOT NULL AUTO_INCREMENT, @@ -67,13 +67,13 @@ `db` text NOT NULL, `query` text NOT NULL, PRIMARY KEY (`id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8""") + ) ENGINE=InnoDB DEFAULT CHARSET=utf8""") curs.execute("""CREATE TABLE `options` ( `name` varchar(50) NOT NULL, `value` text NOT NULL, PRIMARY KEY (`name`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8""") + ) ENGINE=InnoDB DEFAULT CHARSET=utf8""") curs.execute(""" CREATE PROCEDURE makeintervals(startdate timestamp, enddate timestamp, intval integer, unitval varchar(10)) @@ -110,7 +110,7 @@ end repeat; END;""") - curs.execute("""INSERT INTO `options` VALUES ('version', '31')""") + curs.execute("""INSERT INTO `options` VALUES ('version', '32')""") conn.commit() conn.close() diff -r 739af4852be1 -r 5e11cd66721d src/ltpdarepo/upgrade.py --- a/src/ltpdarepo/upgrade.py Fri Jan 04 18:47:43 2013 +0100 +++ b/src/ltpdarepo/upgrade.py Fri Jan 04 18:47:52 2013 +0100 @@ -155,7 +155,7 @@ title TEXT NOT NULL, db TEXT NOT NULL, query TEXT NOT NULL, - PRIMARY KEY (id)) CHARSET=utf8""") + PRIMARY KEY (id)) ENGINE=InnoDB CHARSET=utf8""") # add 'version' field to 'available_dbs' table if not already there curs.execute("DESCRIBE available_dbs") @@ -525,3 +525,15 @@ # switch back to default database curs.execute("USE `%s`" % current) + + +@register(31, 32) +def upgrade_31_32(conn, **kwargs): + logger = logging.getLogger(__name__) + + for table in ('available_dbs', 'options', 'queries', 'users', ): + logger.info(" upgrading storage for table %s", table) + curs = conn.cursor() + curs.execute("ALTER TABLE %s ENGINE=InnoDB" % table) + # commit after each table conversion + conn.commit()