Dispatch: better (aka correct) db_init section
This commit is contained in:
parent
b375a5a049
commit
f09a41bce0
@ -31,10 +31,10 @@ class Dispatch(Module):
|
||||
def db_init(self):
|
||||
"""Set up the database tables, if they don't exist."""
|
||||
|
||||
version = self.db_module_registered(self.__class__.__name__)
|
||||
if (version == None):
|
||||
db = self.get_db()
|
||||
try:
|
||||
db = self.get_db()
|
||||
version = self.db_module_registered(self.__class__.__name__)
|
||||
if version is None:
|
||||
version = 1
|
||||
cur = db.cursor(mdb.cursors.DictCursor)
|
||||
cur.execute('''
|
||||
@ -45,6 +45,16 @@ class Dispatch(Module):
|
||||
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
|
||||
''')
|
||||
|
||||
db.commit()
|
||||
self.db_register_module_version(self.__class__.__name__,
|
||||
version)
|
||||
if version == 1:
|
||||
version = 2
|
||||
cur = db.cursor(mdb.cursors.DictCursor)
|
||||
cur.execute('''
|
||||
ALTER TABLE dispatch_item DROP PRIMARY KEY, ADD PRIMARY KEY (key_, dest)
|
||||
''')
|
||||
|
||||
db.commit()
|
||||
self.db_register_module_version(self.__class__.__name__,
|
||||
version)
|
||||
|
Loading…
Reference in New Issue
Block a user