migrations.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:django-north 作者: peopledoc 项目源码 文件源码
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]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号