Edit File: dbmigrate_lib.cpython-37.opt-1.pyc
B @��c� � @ s� d dl mZ d dl mZ d dlZy$d dlmZ d dlmZmZm Z W nD e k r� Z z&edkrve d�e�� ed� n� W ddZ[X Y nX ej�ej�e�d �Zd d� Zdd � Zdd� Zdd� Zdd� Zddd�ZdS )� )�print_function)�absolute_importN)�MigrationContext)�config�command�script�__main__zkYou need install alembic; yum install alt-python37-alembic or /opt/alt/python37/bin/pip install alembic; {}� zalembic.inic C sJ t � }tj�| �}dd� |�� D �}d}x|rD|�|� |�|�}q*W |S )Nc S s i | ]}|j |jpd �qS )�base)ZrevisionZ down_revision)�.0�s� r �X/opt/alt/python37/lib/python3.7/site-packages/lvestats/utils/dbmigrator/dbmigrate_lib.py� <dictcomp> s z,generate_revisions_chain.<locals>.<dictcomp>r )�listr ZScriptDirectoryZfrom_configZwalk_revisions�append�get)�alembic_cfgZchain_Zscript_Zrevision_pairsZcurent_revisionr r r �generate_revisions_chain s r c C s t �| �}|�� }|pdS )Nr )r Z configureZget_current_revision)Zconn�contextZcurrent_revr r r �get_database_version) s r c C s t | �}|�|�|�|�kS )zq Check need migrate or downgrade to specific revisions :return bool: True - upgrade; False downgrade )r �index)r Z revision_fromZrevision_toZ rev_chainr r r � migration_way/ s r c C s@ | � dd�}| � dd�}tj�tj�||��}| �dd|� | S )zr correct script_location in alembic config for relative path support :param alembic_cfg: :return: �alembicZscript_location�here)Zget_section_option�os�path�abspath�joinZset_section_option)r �locationr Zlocation_correctedr r r �correct_script_location8 s r c C s t tddgd�dd�} | S )Nzlvestats.orm�alembic_version)�fromlistr )�getattr� __import__)r! r r r �get_orm_versionF s r% Fc C s� |d krt � }tt�t��}||jd<