
    MCj                        d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ ej                   Zej"                   eej"                         ej$                  Z e       Zej+                  d
ej,                         ddZde	ddfdZddZ ej4                         r e        y ej6                   e              y)u  
Alembic migration environment.

Wires Alembic's autogenerate feature to the app's actual SQLAlchemy Base
(app/db/models.py) and reads the DB URL from the app's own Settings
rather than duplicating it in alembic.ini — one source of truth for the
connection string.
    N)
fileConfig)context)pool)
Connection)async_engine_from_config)get_settings)Basesqlalchemy.urlreturnc                      t         j                  d      } t        j                  | t        dddi       t        j
                         5  t        j                          d d d        y # 1 sw Y   y xY w)Nr
   T
paramstylenamed)urltarget_metadataliteral_bindsdialect_opts)configget_main_optionr   	configurer   begin_transactionrun_migrations)r   s    8C:\Crop_Prediction\Backend\crop-ai-system\alembic\env.pyrun_migrations_offliner       sa    

 
 !1
2C'"G,	 
	"	"	$ ! ! ! !s   	A''A0
connectionc                     t        j                  | t               t        j                         5  t        j                          d d d        y # 1 sw Y   y xY w)N)r   r   )r   r   r   r   r   )r   s    r   do_run_migrationsr   ,   s?    _M		"	"	$ ! ! ! !s   AAc                  ~  K   t        t        j                  t        j                  i       dt        j
                        } | j                         4 d {   }|j                  t               d {    d d d       d {    | j                          d {    y 7 J7 /7 !# 1 d {  7  sw Y   1xY w7  w)Nzsqlalchemy.)prefix	poolclass)
r   r   get_sectionconfig_ini_sectionr   NullPoolconnectrun_syncr   dispose)connectabler   s     r   run_migrations_onliner'   2   s     *644b9--K
 ""$ 5 5
!!"34445 5



545 5 5 5sf   AB=B B=B&2B"3B&7B=B$B=B;B="B&$B=&B8,B/-B84B=)r   N)__doc__asynciologging.configr   alembicr   
sqlalchemyr   sqlalchemy.enginer   sqlalchemy.ext.asyncior   app.core.configr   app.db.modelsr	   r   config_file_namemetadatar   settingsset_main_optionDATABASE_URLr   r   r'   is_offline_moderun     r   <module>r:      s     %   ( ; ( 		&v&&'-->   ')>)> ?	!!* ! !  7GKK%'(r9   