
    g]                        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rd d	lmZ  ej                  ej                        	 	 	 	 	 	 dd       Z ej                  ej"                        dd       Z ej                  ej&                        	 	 	 	 	 	 dd       Z ej                  ej*                        	 	 	 	 	 	 dd       Z ej                  ej.                        dd       Z ej                  ej2                        	 	 	 	 	 	 dd       Z ej                  ej6                        	 	 	 	 	 	 dd       Z ej                  ej:                        	 	 	 	 	 	 d d       Z ej                  ej>                        	 	 	 	 	 	 d!d       Z  ej                  ejB                        d"d       Z" ej                  ejF                        	 	 	 	 	 	 d#d       Z$ ej                  ejJ                        	 	 	 	 	 	 d$d       Z& ej                  ejN                        	 	 	 	 	 	 d%d       Z( ej                  ejR                        	 	 	 	 	 	 d&d       Z*y
)'    )TYPE_CHECKINGschema   )ops)
Operations   )_copy)sqla_14)TableNc                    | j                   j                  j                  | j                   j                  d       |j                  }|j                  }|j
                  }|j                  }|j                  }|j                  }|j                  }|j                  }	|j                  }
|j                  }|j                  }|j                  }fd}|ri|rg| j                  j!                  |t#        j$                  ||      |      }|j&                  D ]&  } ||      s| j                   j)                  |       (  | j                   j*                  ||f||	|
|||||||d
|j,                   |rn| j                  j!                  || j                  j/                  ||      |      }|j&                  D ]&  } ||      s| j                   j1                  |       ( y y )Nc                 ~    t        | t        j                         xr  | j                   xs | j                        S N)
isinstance	sa_schemaPrimaryKeyConstraint_create_rule)
constraintcompilers    X/var/www/html/AdoubleTech/venv/lib/python3.12/site-packages/alembic/operations/toimpl.py_count_constraintz'alter_column.<locals>._count_constraint&   s<    j)*H*HII 
'''L:+B+B8+L	
    r   )
nullableserver_defaultnametype_r   existing_typeexisting_server_defaultexisting_nullablecommentexisting_comment)impldialectstatement_compilerr   r   r   modify_typecolumn_name
table_namer   modify_server_defaultmodify_namemodify_nullablemodify_commentr!   
schema_objtabler   Columnconstraintsdrop_constraintalter_columnkwcolumnadd_constraint)
operations	operationr   r   r   r   r&   r'   r   r   new_column_namer   r    r!   r   tr   r   s                    @r   r1   r1      s    &&99H ++M!33'??!!E''K%%JF44N++O((H&&G 11

 !!''[-8 ( 

 -- 	<J ,//
;	< !JOO   %# 7+) ,,  !!''!!((e< ( 

 -- 	;J ,..z:	; r   c                     i }|j                    t        st        d      |j                   |d<    | j                  j                  |j                  | j                        fi | y NSQLAlchemy 1.4+ required	if_exists)r<   r   NotImplementedErrorr"   
drop_tableto_tablemigration_contextr5   r6   r2   s      r   r>   r>   P   sa    	B&%&@AA#--;JOO:778<>r   c                     |j                  | j                        } | j                  j                  |j                  |fd|j
                  i|j                   y )Nr   )	to_columnr@   r"   drop_columnr'   r   r2   )r5   r6   r3   s      r   rD   rD   ]   sS       !=!=>FJOOf-6-=-=AJr   c                     |j                  | j                        }i }|j                   t        st	        d      |j                  |d<    | j
                  j                  |fi | y Nr;   if_not_exists)to_indexr@   rG   r   r=   r"   create_index)r5   r6   idxr2   s       r   rI   rI   g   sc     

Z99
:C	B*%&@AA'55? JOO  ++r   c                     i }|j                    t        st        d      |j                   |d<    | j                  j                  |j                  | j                        fi | y r:   )r<   r   r=   r"   
drop_indexrH   r@   rA   s      r   rL   rL   u   sa    	B&%&@AA#--;JOO:778
r   c                     i }|j                    t        st        d      |j                   |d<   |j                  | j                        } | j
                  j                  |fi | |S rF   )rG   r   r=   r?   r@   r"   create_table)r5   r6   r2   r-   s       r   rN   rN      sh     
B*%&@AA'55?z;;<E JOO  -"-Lr   c                 |    | j                   j                  |j                  |j                  |j                         y Nr   )r"   rename_tabler'   new_table_namer   r5   r6   s     r   rQ   rQ      s4     OO  i66y?O?O ! r   c                 p    |j                  | j                        }| j                  j                  |       y r   )r?   r@   r"   create_table_commentr5   r6   r-   s      r   rU   rU      s,     z;;<EOO((/r   c                 p    |j                  | j                        }| j                  j                  |       y r   )r?   r@   r"   drop_table_commentrV   s      r   rX   rX      s,     z;;<EOO&&u-r   c                    |j                   }|j                  }|j                  }|j                  }|j                  t        |      }| j                  j	                  |||      } | j                  j                  ||fd|i| |j                  D ]8  }t        |t        j                        r| j                  j                  |       : |j                  D ]  }| j                  j                  |        | j                  j                   j"                  xr! | j                  j                   j$                   }	|j&                  }
|
r|	r| j                  j)                  |       y y y )Nr   r   )r'   r3   r   r2   r-   r
   r,   r"   
add_columnr/   r   r   r   r4   indexesrI   r#   supports_commentsinline_commentsr    create_column_comment)r5   r6   r'   r3   r   r2   r8   r   indexwith_commentr    s              r   rZ   rZ      s6   %%JFF	B||v##Jv#FAJOOz6G&GBGmm 7
*i&D&DEOO**:67  ,$$U+, 	11 	8''777  nnG<--f5  wr   c                 l    | j                   j                  |j                  | j                               y r   )r"   r4   to_constraintr@   rS   s     r   create_constraintrc      s*     OO""
 < <=r   c                     | j                   j                  | j                  j                  |j                  |j
                  |j                  |j                               y rP   )r"   r0   r,   generic_constraintconstraint_namer'   constraint_typer   rS   s     r   r0   r0      sS     OO##00%%  %%##	 	1 	
r   c                 |    | j                   j                  |j                  |j                  |j                         y )N)multiinsert)r"   bulk_insertr-   rowsri   rS   s     r   rj   rj      s0     OOY5J5J   r   c                 z    | j                   j                  j                  |j                  |j                         y )N)execution_options)r@   r"   executesqltextrm   rS   s     r   execute_sqlrp      s4       %%--Y-H-H . r   )r5   r   r6   zops.AlterColumnOpreturnN)r5   r   r6   zops.DropTableOprq   N)r5   r   r6   zops.DropColumnOprq   N)r5   r   r6   zops.CreateIndexOprq   N)r5   r   r6   zops.DropIndexOprq   N)r5   r   r6   zops.CreateTableOprq   r   )r5   r   r6   zops.RenameTableOprq   N)r5   r   r6   zops.CreateTableCommentOprq   N)r5   r   r6   zops.DropTableCommentOprq   N)r5   r   r6   zops.AddColumnOprq   N)r5   r   r6   zops.AddConstraintOprq   N)r5   r   r6   zops.DropConstraintOprq   N)r5   r   r6   zops.BulkInsertOprq   N)r5   r   r6   zops.ExecuteSQLOprq   N)+typingr   
sqlalchemyr   r    r   baser   util.sqla_compatr
   r   sqlalchemy.sql.schemar   implementation_forAlterColumnOpr1   DropTableOpr>   DropColumnOprD   CreateIndexOprI   DropIndexOprL   CreateTableOprN   RenameTableOprQ   CreateTableCommentOprU   DropTableCommentOprX   AddColumnOprZ   AddConstraintOprc   DropConstraintOpr0   BulkInsertOprj   ExecuteSQLOprp    r   r   <module>r      sD   ! *   $ &+ s001;;;;)<;;	;; 2;;| s/	 0	 s//0);	 1 s001
,
,)<
,	
, 2
, s/ 0 s001)< 2 s001)<	 2 s77800)C0	0 90 s556..)A.	. 7. s/6 066 s223)>	 4 s334

)?
	
 5
 s//0);	 1 s//0);	 1r   