Implement database upgrade for indexes
[cascardo/ipsilon.git] / ipsilon / util / sessions.py
index ef059d1..8df3b4d 100644 (file)
@@ -23,7 +23,17 @@ class SessionStore(Store):
         q.create()
 
     def _upgrade_schema(self, old_version):
-        raise NotImplementedError()
+        if old_version == 1:
+            # In schema version 2, we added indexes and primary keys
+            # pylint: disable=protected-access
+            table = self._query(self._db, 'sessions', SESSION_TABLE,
+                                trans=False)._table
+            self._db.add_constraint(table.primary_key)
+            for index in table.indexes:
+                self._db.add_index(index)
+            return 2
+        else:
+            raise NotImplementedError()
 
 
 class SqlSession(Session):