Add new DB table last_archive_message

This commit is contained in:
Philipp Hörist 2017-11-13 19:20:11 +01:00
parent 536a504f69
commit 52827c6add
3 changed files with 30 additions and 1 deletions

View File

@ -1,6 +1,6 @@
import subprocess
__version__ = "0.16.11.1"
__version__ = "0.16.11.2"
try:
node = subprocess.Popen('git rev-parse --short=12 HEAD', shell=True,

View File

@ -80,6 +80,13 @@ def create_log_db():
marker INTEGER
);
CREATE TABLE last_archive_message(
jid_id INTEGER PRIMARY KEY UNIQUE,
last_mam_id TEXT,
oldest_mam_timestamp TEXT,
last_muc_timestamp TEXT
);
CREATE INDEX idx_logs_jid_id_time ON logs (jid_id, time DESC);
'''
)

View File

@ -242,6 +242,8 @@ class OptionsParser:
self.update_config_to_016105()
if old < [0, 16, 11, 1] and new >= [0, 16, 11, 1]:
self.update_config_to_016111()
if old < [0, 16, 11, 2] and new >= [0, 16, 11, 2]:
self.update_config_to_016112()
app.logger.init_vars()
app.logger.attach_cache_database()
@ -1029,3 +1031,23 @@ class OptionsParser:
log.exception('Error')
con.close()
app.config.set('version', '0.16.11.1')
def update_config_to_016112(self):
con = sqlite.connect(logger.LOG_DB_PATH)
cur = con.cursor()
try:
cur.executescript(
'''
CREATE TABLE IF NOT EXISTS last_archive_message(
jid_id INTEGER PRIMARY KEY UNIQUE,
last_mam_id TEXT,
oldest_mam_timestamp TEXT,
last_muc_timestamp TEXT
);
'''
)
con.commit()
except sqlite.OperationalError:
log.exception('Error')
con.close()
app.config.set('version', '0.16.11.2')