clean logs table so that show field contains only 0, 1, 2, 3, 4, 5 values

This commit is contained in:
Yann Leboulanger 2006-10-08 09:57:23 +00:00
parent 182963242b
commit 5c615f53b5
2 changed files with 29 additions and 8 deletions

View File

@ -141,7 +141,7 @@ class Config:
'send_on_ctrl_enter': [opt_bool, False, _('Send message on Ctrl+Enter and with Enter make new line (Mirabilis ICQ Client default behaviour).')],
'show_roster_on_startup': [opt_bool, True],
'key_up_lines': [opt_int, 25, _('How many lines to store for Ctrl+KeyUP.')],
'version': [ opt_str, '0.10.1.4' ], # which version created the config
'version': [ opt_str, '0.10.1.5' ], # which version created the config
'search_engine': [opt_str, 'http://www.google.com/search?&q=%s&sourceid=gajim'],
'dictionary_url': [opt_str, 'WIKTIONARY', _("Either custom url with %s in it where %s is the word/phrase or 'WIKTIONARY' which means use wiktionary.")],
'always_english_wikipedia': [opt_bool, False],

View File

@ -147,6 +147,8 @@ class OptionsParser:
self.update_config_to_01013()
if old < [0, 10, 1, 4] and new >= [0, 10, 1, 4]:
self.update_config_to_01014()
if old < [0, 10, 1, 5] and new >= [0, 10, 1, 5]:
self.update_config_to_01015()
gajim.logger.init_vars()
gajim.config.set('version', new_version)
@ -315,13 +317,32 @@ class OptionsParser:
con = sqlite.connect(logger.LOG_DB_PATH)
cur = con.cursor()
# apply indeces
cur.executescript(
'''
CREATE INDEX idx_logs_jid_id_kind ON logs (jid_id, kind);
CREATE INDEX idx_unread_messages_jid_id ON unread_messages (jid_id);
'''
)
try:
cur.executescript(
'''
CREATE INDEX idx_logs_jid_id_kind ON logs (jid_id, kind);
CREATE INDEX idx_unread_messages_jid_id ON unread_messages (jid_id);
'''
)
con.commit()
con.commit()
except:
pass
con.close()
gajim.config.set('version', '0.10.1.4')
def update_config_to_01015(self):
'''clean show values in logs database'''
from pysqlite2 import dbapi2 as sqlite
import logger
con = sqlite.connect(logger.LOG_DB_PATH)
cur = con.cursor()
status = dict((i[5:].lower(), logger.constants.__dict__[i]) for i in \
logger.constants.__dict__.keys() if i.startswith('SHOW_'))
for show in status:
cur.execute('update logs set show = ? where show = ?;', (status[show],
show))
cur.executescript('update logs set show = NULL where show not in (0, 1, 2, 3, 4, 5);')
con.commit()
con.close()
gajim.config.set('version', '0.10.1.5')