
    g              	          S SK r S SKrS SKJr  S SKJr  S SKJr  S SKJ	r	  Sr
\	R                  r\" \R                  5        \R                  " S5      rSS jrSS	 jr\R#                  S
\" 5       5        / r\R                  R'                  S5      b$  \" \R                  S   R+                  5       5      rO/\" \R.                  S   R0                  SS5      r\(       a  \" 5       r\ H$  r\	R                  R7                  \S
\" \S95        M&     \R.                  S   R0                  rS rS rS rS r \	RB                  " 5       (       a  \" 5         g\ RD                  " 5       RG                  \ " 5       5        g)    N)
fileConfig)MetaData)current_app)contextFzalembic.envc                      [         R                  S   R                  R                  U S9$ ! [        [
        4 a9    [         R                  S   R                  R                  R                  U 5      s $ f = f)Nmigrate)bind)r   
extensionsdb
get_engine	TypeErrorAttributeErrorenginesgetbind_keys    t/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/flask_migrate/templates/aioflask-multidb/env.pyr   r      sk    J%%i033>>H>MM~& J%%i033;;??IIJs   ), AA54A5c                      [        U 5      R                  R                  SS9R                  SS5      $ ! [         a1    [        [        U 5      R                  5      R                  SS5      s $ f = f)NF)hide_password%z%%)r   urlrender_as_stringreplacer   strr   s    r   get_engine_urlr      sn    @(#''88 9 !!(d!3	4 @:h'++,44S$??@s   14 8A/.A/sqlalchemy.urlSQLALCHEMY_BINDSr   
bind_namesr   c                 <   U S:X  a  Sn [        [        S5      (       a  [        R                  U    $ [        5       n[        R                  R
                  R                  5        H5  nUR                  R                  S5      U :X  d  M$  UR                  U5        M7     U$ )zReturn the metadata for a bind. N	metadatasr   )
hasattr	target_dbr!   r   metadatatablesvaluesinfor   
tometadata)r	   mts      r   get_metadatar+   @   s{    rzy+&&""4(( 	
A&&--/66::j!T)LLO 0 H    c            	      ~   SS[         R                  R                  S5      00n [         H,  n0 =X'   n[         R                  R	                  US5      US'   M.     U R                  5        H  u  p[        R                  SU=(       d    S-  5        SU-  n[        R                  SU-  5        [        US5       n[         R                  " US   U[        U5      S	S
9  [         R                  " 5          [         R                  " US9  SSS5        SSS5        M     g! , (       d  f       N= f! , (       d  f       M  = f)a*  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.

r    r   r   Migrating database %s	<default>z%s.sqlzWriting output to %swT)r   output_buffertarget_metadataliteral_bindsengine_nameN)r   configget_main_optionr   get_section_optionitemsloggerr'   open	configurer+   begin_transactionrun_migrations)r   namerecfile_buffers        r   run_migrations_offlinerC   O   s     	7>>112BC
G
   ^^66t=MNE
  ]]_	+t/B{CD4*U23%J$ ,T 2"	 **,&&48 - 	 % -, s$   99D-2DD-
D*&D--
D<	c           
         S n[         R                  S   R                  nUR                  S5      c  X#S'   UR	                  5        HP  u  pEUS   R                  5       =US'   n[        (       a  UR                  5       US'   M=  UR                  5       US'   MR      UR	                  5        Hg  u  pE[        R                  SU=(       d    S-  5        [        R                  " SUS   S	U-  S
U-  [        U5      S.UD6  [        R                  " US9  Mi     [        (       a*  UR                  5        H  nUS   R!                  5         M     UR                  5        H  nUS   R#                  5         M      UR                  5        H  nUS   R'                  5         M     g !   UR                  5        H  nUS   R%                  5         M     e = f! UR                  5        H  nUS   R'                  5         M     f = f)Nc                 D   [        [        R                  SS5      (       a  US   n[        UR                  5      [        [
        5      S-   :  aQ  SnUR                   H  nUR                  5       (       a  M  SnM     U(       a  / US S & [        R                  S5        g g g g )NautogenerateFr      TzNo changes in schema detected.)	getattrr6   cmd_optslenupgrade_ops_listr   is_emptyr:   r'   )r   revision
directivesscriptemptyupgrade_opss         r   process_revision_directives6do_run_migrations.<locals>.process_revision_directivesz   s    6??NE::]F6**+s:/BB#)#:#:K&//11 % $; $&JqMKK @A  C ;r,   r   rR   
connectionsync_connectiontransactionr.   r/   z%s_upgradesz%s_downgrades)rT   upgrade_tokendowngrade_tokenr2   r4    )r   r
   configure_argsr   r9   _sync_connectionUSE_TWOPHASEbegin_twophasebeginr:   r'   r   r<   r+   r>   r&   preparecommitrollbackclose)_r   rR   	conf_argsr?   r@   conns          r   do_run_migrationsrf   v   s   
B &&y1@@I}}23;3N/0]]_	(+L(9(J(J(LL<!%!4!4!6C!%C %+ IDKK/43F;GH 01+d2 /$ 6 ,T 2	
  ""t4 ) <~~'M"**, ( >>#C%%' $ >>#C!"((* $>>#C'') $>>#C!"((* $s   CF" "-GG ,G>c                    #    SS[        5       00n [         H  n0 =X'   n[        US9US'   M     U R                  5        H3  u  pUS   nUR                  5       R	                  5       I Sh  vN US'   M5     U S   S   R                  [        U 5      I Sh  vN   U R                  5        H  nUS   R                  5       I Sh  vN   M      g Nb N9 N7f)z}Run migrations in 'online' mode.

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

r    enginer   NrT   )	r   r   r9   connectstartrun_syncrf   r&   rb   )r   r?   r@   rh   s       r   run_migrations_onlinerl      s      	Xz|$G   "D1H  ]]_	X"(.."2"8"8"::L % "+l
#
,
,->
HHH~~,%%'''  	 ;H 	(s6   A)C+C,*CC-CC
CCC)N)$asynciologginglogging.configr   
sqlalchemyr   flaskr   alembicr   r\   r6   config_file_name	getLoggerr:   r   r   set_main_optionr   r   listkeysrH   r
   r   get_bind_namesr	   set_section_optionr#   r+   rC   rf   rl   is_offline_modeget_event_looprun_until_completerY   r,   r   <module>r}      s[     %    
 6"" #			=	)J@   ')9 :
,-9k(();<AACDJ[33I>AA)41N#%
DNN%% =?  ""9-00	$9N3+l(6 //0E0GHr,   