Fix initialization of plugin_data table in AdminStore
authorPatrick Uiterwijk <puiterwijk@redhat.com>
Thu, 3 Sep 2015 14:30:47 +0000 (16:30 +0200)
committerPatrick Uiterwijk <puiterwijk@redhat.com>
Thu, 3 Sep 2015 14:36:56 +0000 (16:36 +0200)
This was created ad-hoc before, but now has to be created by the
upgrade script.

Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Reviewed-by: Rob Crittenden <rcritten@redhat.com>
ipsilon/tools/dbupgrade.py
ipsilon/util/data.py
ipsilon/util/plugin.py

index 16eebb6..e6d2b16 100644 (file)
@@ -56,12 +56,12 @@ def execute_upgrade(cfgfile):
     # pylint: disable=protected-access
     Store._is_upgrade = True
 
-    datastore = AdminStore()
+    adminstore = AdminStore()
     # First try to upgrade the config store before continuing
-    if not _upgrade_database(datastore):
+    if not _upgrade_database(adminstore):
         return upgrade_failed()
 
-    admin_config = datastore.load_config()
+    admin_config = adminstore.load_config()
     for option in admin_config:
         cherrypy.config[option] = admin_config[option]
 
@@ -95,6 +95,8 @@ def execute_upgrade(cfgfile):
         for plugin in root._site[facility].enabled:
             print 'Handling plugin %s' % plugin
             plugin = root._site[facility].available[plugin]
+            print 'Creating plugin AdminStore table'
+            adminstore.create_plugin_data_table(plugin.name)
             for store in plugin.used_datastores():
                 print 'Handling plugin datastore %s' % store.__class__.__name__
                 if not _upgrade_database(store):
index 79b7156..835924d 100644 (file)
@@ -617,6 +617,12 @@ class AdminStore(Store):
         else:
             raise NotImplementedError()
 
+    def create_plugin_data_table(self, plugin_name):
+        table = plugin_name+'_data'
+        q = self._query(self._db, table, UNIQUE_DATA_TABLE,
+                        trans=False)
+        q.create()
+
 
 class UserStore(Store):
 
index 978e470..6aecbf6 100644 (file)
@@ -150,6 +150,7 @@ class PluginObject(Log):
         try:
             Store._is_upgrade = True  # pylint: disable=protected-access
             self.on_enable()
+            self._data.create_plugin_data_table(self.name)
             for store in self.used_datastores():
                 store.upgrade_database()
         finally: