diff --git a/src/common/check_paths.py b/src/common/check_paths.py
index 18c0bdca13beb8d93f315181e84d4729f00ccaf0..396db51da33079a37aba3c35dec6d3a518ac0df9 100644
--- a/src/common/check_paths.py
+++ b/src/common/check_paths.py
@@ -57,7 +57,8 @@ def create_log_db():
 		);
 		
 		CREATE TABLE unread_messages(
-			message_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE
+			message_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
+			jid_id INTEGER
 		);
 		
 		CREATE TABLE logs(
@@ -74,6 +75,7 @@ def create_log_db():
 		)
 
 	con.commit()
+	con.close()
 
 def check_and_possibly_create_paths():
 	LOG_DB_PATH = logger.LOG_DB_PATH
@@ -105,6 +107,7 @@ def check_and_possibly_create_paths():
 
 		if not os.path.exists(LOG_DB_PATH):
 			create_log_db()
+			gajim.logger.init_vars()
 		elif os.path.isdir(LOG_DB_PATH):
 			print _('%s is directory but should be file') % LOG_DB_PATH
 			print _('Gajim will now exit')
diff --git a/src/migrate_logs_to_dot9_db.py b/src/migrate_logs_to_dot9_db.py
index 94281cd4d9068b0d520b009f6c67ce11c585335e..7566dd91c946bcbbd910daa3fc33d995a1c5b389 100755
--- a/src/migrate_logs_to_dot9_db.py
+++ b/src/migrate_logs_to_dot9_db.py
@@ -217,7 +217,12 @@ class Migration:
 				jid TEXT UNIQUE,
 				type INTEGER
 			);
-	
+
+			CREATE TABLE unread_messages(
+				message_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
+				jid_id INTEGER
+			);
+			
 			CREATE TABLE logs(
 				log_line_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
 				jid_id INTEGER,