def get_current_version_from_table():
"""
Return the current version of the database, from sql_version table.
Return None if the table does not exist (schema not inited).
"""
with connection.cursor() as cursor:
try:
cursor.execute("SELECT version_num FROM sql_version;")
except ProgrammingError:
# table does not exist ?
return None
rows = cursor.fetchall()
versions = [row[0] for row in rows if is_version(row[0])]
if not versions:
return None
# sort versions
versions.sort(key=StrictVersion)
# return the last one
return versions[-1]
评论列表
文章目录