changeset 257:5e11cd66721d

Convert all tables to InnoDB storage. Bump schema revision to 32.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Fri, 04 Jan 2013 18:47:52 +0100
parents 739af4852be1
children 773d9567dcb2
files src/ltpdarepo/__init__.py src/ltpdarepo/install.py src/ltpdarepo/upgrade.py
diffstat 3 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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()
--- 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()