
    g.              	          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   R.                  SS5      r\(       a  \" 5       r\ H$  r\R                  R5                  \S
\" \S95        M&     \R,                  S   R.                  rS rS rS r\R>                  " 5       (       a  \" 5         g\" 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    q/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/flask_migrate/templates/flask-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   M   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'   SS[	        5       00n[
         H  n0 =X#'   n[	        US9US'   M     UR                  5        HR  u  p4US   nUR                  5       =US'   n[        (       a  UR                  5       US	'   M?  UR                  5       US	'   MT      UR                  5        Hg  u  p4[        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)z}Run migrations in 'online' mode.

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

c                 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_directives:run_migrations_online.<locals>.process_revision_directives   s    6??NE::]F6**+s:/BB#)#:#:K&//11 % $; $&JqMKK @A  C ;r,   r   rR   Nr    enginer   
connectiontransactionr.   r/   z%s_upgradesz%s_downgrades)rU   upgrade_tokendowngrade_tokenr2   r4    )r   r
   configure_argsr   r   r   r9   connectUSE_TWOPHASEbegin_twophasebeginr:   r'   r   r<   r+   r>   r&   preparecommitrollbackclose)rR   	conf_argsr   r?   r@   rT   conns          r   run_migrations_onlinere   t   s
   
B &&y1@@I}}23;3N/0
 	Xz|$G   "D1H  ]]_	X#)>>#33LD<!%!4!4!6C!%C %& IDKK/43F;GH |,+d2 /$ 6 ,T 2	
  ""t4 ) <~~'M"**, ( >>#C%%' $ >>#C##% $>>#C'') $>>#C##% $s   CG -G>>H ,H-)N) 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   re   is_offline_moderY   r,   r   <module>rs      s?    %    
 6"" #			=	)J@   ')9 :
,-9k(();<AACDJ[33I>AA)41N#%
DNN%% =?  ""9-00	$9NE&P r,   