Notify the user about DB migrations
This commit is contained in:
parent
4652642bcd
commit
5ad14b01b4
@ -35,6 +35,18 @@ class SqliteSessionManager(SimpleSessionManager):
|
|||||||
SimpleSessionManager.__init__(self)
|
SimpleSessionManager.__init__(self)
|
||||||
|
|
||||||
self.session_db_path = os.path.realpath(session_db_path)
|
self.session_db_path = os.path.realpath(session_db_path)
|
||||||
|
self._ensure_schema_up_to_date()
|
||||||
|
|
||||||
|
def _ensure_schema_up_to_date(self):
|
||||||
|
conn = self._conn()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute("SELECT * FROM sqlite_master "
|
||||||
|
"WHERE sql LIKE '%user VARCHAR PRIMARY KEY%' "
|
||||||
|
"AND tbl_name = 'session'")
|
||||||
|
res = cursor.fetchone()
|
||||||
|
conn.close()
|
||||||
|
if res is not None:
|
||||||
|
raise Exception("Outdated database schema, run utils/migrate_user_tables.py")
|
||||||
|
|
||||||
def _conn(self):
|
def _conn(self):
|
||||||
new = not os.path.exists(self.session_db_path)
|
new = not os.path.exists(self.session_db_path)
|
||||||
|
|||||||
@ -44,7 +44,20 @@ class SqliteUserManager(SimpleUserManager):
|
|||||||
|
|
||||||
def __init__(self, auth_db_path, collection_path=None):
|
def __init__(self, auth_db_path, collection_path=None):
|
||||||
SimpleUserManager.__init__(self, collection_path)
|
SimpleUserManager.__init__(self, collection_path)
|
||||||
|
|
||||||
self.auth_db_path = os.path.realpath(auth_db_path)
|
self.auth_db_path = os.path.realpath(auth_db_path)
|
||||||
|
self._ensure_schema_up_to_date()
|
||||||
|
|
||||||
|
def _ensure_schema_up_to_date(self):
|
||||||
|
conn = self._conn()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute("SELECT * FROM sqlite_master "
|
||||||
|
"WHERE sql LIKE '%user VARCHAR PRIMARY KEY%' "
|
||||||
|
"AND tbl_name = 'auth'")
|
||||||
|
res = cursor.fetchone()
|
||||||
|
conn.close()
|
||||||
|
if res is not None:
|
||||||
|
raise Exception("Outdated database schema, run utils/migrate_user_tables.py")
|
||||||
|
|
||||||
# Default to using sqlite3 but overridable for sub-classes using other
|
# Default to using sqlite3 but overridable for sub-classes using other
|
||||||
# DB API 2 driver variants
|
# DB API 2 driver variants
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user