3
( \(                 @   s   d dl mZ d dlmZ d dlmZmZ d dlZejZej	dZ
d dlmZ ejdejjd ejd	 jjZd
d Zdd Zej re  ne  dS )    )with_statement)context)engine_from_configpoolNzalembic.env)current_appzsqlalchemy.urlZSQLALCHEMY_DATABASE_URImigratec           	   C   s6   t jd} tj| d tj  tj  W dQ R X dS )aF  Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.

    Calls to context.execute() here emit the given string to the
    script output.

    zsqlalchemy.url)urlN)configZget_main_optionr   	configurebegin_transactionrun_migrations)r    r   )/usr/share/pgadmin4/web/migrations/env.pyrun_migrations_offline&   s    

r   c              C   sx   dd } t tjtjdtjd}|j }tjf |t	| dt
jd j z tj  tj  W dQ R X W d|j  X dS )zRun migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    c             S   s:   t tjddr6|d }|jj r6g |d d < tjd d S )NZautogenerateFr   zNo changes in schema detected.)getattrr	   Zcmd_optsZupgrade_opsZis_emptyloggerinfo)r   ZrevisionZ
directivesZscriptr   r   r   process_revision_directivesD   s
    
z:run_migrations_online.<locals>.process_revision_directiveszsqlalchemy.)prefixZ	poolclass)
connectiontarget_metadatar   r   N)r   r	   Zget_sectionZconfig_ini_sectionr   ZNullPoolZconnectr   r
   r   r   
extensionsZconfigure_argsr   r   close)r   Zenginer   r   r   r   run_migrations_online9   s    

r   )Z
__future__r   Zalembicr   Z
sqlalchemyr   r   Zloggingr	   Z	getLoggerr   Zflaskr   Zset_main_optiongetr   ZdbZmetadatar   r   r   Zis_offline_moder   r   r   r   <module>
   s   
"