
    Oj!                     F   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                  d0d            Z ej        ej                  	 	 	 	 	 	 d1d            Z ej        ej                  	 	 	 	 	 	 d2d            Z ej        ej                  	 	 	 	 	 	 d3d            Z ej        ej                  	 	 	 	 	 	 d4d!            Z  ej        ej!                  d5d#            Z" ej        ej#                  	 	 	 	 	 	 d6d%            Z$ ej        ej%                  	 	 	 	 	 	 d7d'            Z& ej        ej'                  	 	 	 	 	 	 d8d)            Z( ej        ej)                  	 	 	 	 	 	 d9d+            Z*dS ):    )TYPE_CHECKINGschema   )ops)
Operations   )_copy)sqla_2)Table
operationsr   	operationops.AlterColumnOpreturnNc                    | j         j                            | j         j        d           |j        }|j        }|j        }|j        }|j        }|j        }|j	        }|j
        }	|j        }
|j        }|j        }|j        }fd}|ra|r_| j                            |t#          j        ||          |          }|j        D ]'} ||          r| j                             |           (|dusJ |dusJ  | j         j        ||f||	|
|||||||d
|j         |re| j                            || j                            ||          |          }|j        D ])} ||          r| j                             |           (d S d S )Nc                 t    t          | t          j                   o| j         p|                               S N)
isinstance	sa_schemaPrimaryKeyConstraint_create_rule)
constraintcompilers    m/lsinfo/ai/hellotax_ai/training_center/backend/venv/lib/python3.11/site-packages/alembic/operations/toimpl.py_count_constraintz'alter_column.<locals>._count_constraint&   s<    j)*HIII 
''L:+B+B8+L+L	
    r   T)
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)r   r   r!   r#   r"   r    r*   r+   r   r   new_column_namer   r$   r%   r   tr   r   s                    @r   r5   r5      s5    &99 H +M!3'?!E'K%JF4N+O(H&G 1
 
 
 
 

  < <!''[-88 ( 
 

 - 	< 	<J  ,, <//
;;; #$....$ JO  %# 7+)  ,     ;!''!((e<< ( 
 

 - 	; 	;J  ,, ;..z:::; ;	; 	;r   ops.DropTableOpc                     i }|j         
|j         |d<    | j        j        |                    | j                  fi | d S N	if_exists)r>   r&   
drop_tableto_tablemigration_contextr   r   r6   s      r   r?   r?   U   s`    	B&#-;JO:788 <>    r   ops.DropColumnOpc                     |                     | j                  } | j        j        |j        |f|j        |j        d|j         d S )N)r   r>   )	to_columnrA   r&   drop_columnr+   r   r>   r6   )r   r   r7   s      r   rF   rF   _   sj       !=>>FJO %	 
 ,    r   ops.CreateIndexOpc                     |                     | j                  }i }|j        
|j        |d<    | j        j        |fi | d S Nif_not_exists)to_indexrA   rJ   r&   create_index)r   r   idxr6   s       r   rL   rL   m   sX     

Z9
:
:C	B*'5? JO +++++++r   ops.DropIndexOpc                     i }|j         
|j         |d<    | j        j        |                    | j                  fi | d S r=   )r>   r&   
drop_indexrK   rA   rB   s      r   rP   rP   x   s`    	B&#-;JO:788 
    r   ops.CreateTableOpr   c                     i }|j         
|j         |d<   |                    | j                  } | j        j        |fi | |S rI   )rJ   r@   rA   r&   create_table)r   r   r6   r1   s       r   rS   rS      sW     
B*'5?z;<<E JO --"---Lr   ops.RenameTableOpc                 ^    | j                             |j        |j        |j                   d S )Nr   )r&   rename_tabler+   new_table_namer   r   r   s     r   rV   rV      s=     O  i6y?O !     r   ops.CreateTableCommentOpc                 n    |                     | j                  }| j                            |           d S r   )r@   rA   r&   create_table_commentr   r   r1   s      r   r[   r[      s6     z;<<EO((/////r   ops.DropTableCommentOpc                 n    |                     | j                  }| j                            |           d S r   )r@   rA   r&   drop_table_commentr\   s      r   r_   r_      s6     z;<<EO&&u-----r   ops.AddColumnOpc                    |j         }|j        }|j        }|j        }|j        }|j        }|j        t          |          }| j                            |||          } | j	        j
        ||f||j        ||d| |j        D ]}	t          |	t          j                  sg|rKt          |	t          j                  r1t#          |j                  dk    rt#          |	j                  dk    ri| j	                            |	           |j        D ]}
| j	                            |
           | j	        j        j        o| j	        j        j         }|j        }|r|r| j	                            |           d S d S d S )Nr   )r   rJ   inline_referencesinline_primary_keyr   )r+   r7   r   r6   rb   rc   r1   r
   r0   r&   
add_columnrJ   r3   r   r   r   ForeignKeyConstraintlenforeign_keyscolumnsr8   indexesrL   r'   supports_commentsinline_commentsr$   create_column_comment)r   r   r+   r7   r   r6   rb   rc   r:   r   indexwith_commentr$   s                r   rd   rd      s   %JFF	B!3"5|v##Jv#FFAJO -+-     m 7 7
*i&DEE 	7
 "z9+IJJ +,,11
*++q00O**:666 , ,$$U++++ 	1 	8'77  nG 6< 6--f555556 6 6 6r   ops.AddConstraintOpc                 j    | j                             |                    | j                             d S r   )r&   r8   to_constraintrA   rX   s     r   create_constraintrr      s<     O""
 <==    r   ops.DropConstraintOpc                     i }|j          t          st          d          |j         |d<    | j        j        | j                            |j        |j        |j	        |j
                  fi | d S )NzSQLAlchemy 2.0 requiredr>   r   )r>   r   NotImplementedErrorr&   r4   r0   generic_constraintconstraint_namer+   constraint_typer   rB   s      r   r4   r4      s     
B& 	A%&?@@@#-;#JO#00% %#	 	1 	
 	
      r   ops.BulkInsertOpc                 ^    | j                             |j        |j        |j                   d S )N)multiinsert)r&   bulk_insertr1   rowsr{   rX   s     r   r|   r|      s;     OY5J       r   ops.ExecuteSQLOpc                 \    | j         j                            |j        |j                   d S )N)execution_options)rA   r&   executesqltextr   rX   s     r   execute_sqlr      s<      %--Y-H .     r   )r   r   r   r   r   N)r   r   r   r;   r   N)r   r   r   rC   r   N)r   r   r   rG   r   N)r   r   r   rN   r   N)r   r   r   rQ   r   r   )r   r   r   rT   r   N)r   r   r   rY   r   N)r   r   r   r]   r   N)r   r   r   r`   r   N)r   r   r   ro   r   N)r   r   r   rs   r   N)r   r   r   ry   r   N)r   r   r   r~   r   N)+typingr   
sqlalchemyr   r    r   baser   util.sqla_compatr
   r   sqlalchemy.sql.schemar   implementation_forAlterColumnOpr5   DropTableOpr?   DropColumnOprF   CreateIndexOprL   DropIndexOprP   CreateTableOprS   RenameTableOprV   CreateTableCommentOpr[   DropTableCommentOpr_   AddColumnOprd   AddConstraintOprr   DropConstraintOpr4   BulkInsertOpr|   ExecuteSQLOpr    r   r   <module>r      sS   !           * * * * * *             $ $ $ $ $ $ % % % % % % ,++++++ s011@;@;)<@;	@; @; @; 21@;F s//   0/ s/00

);
	
 
 
 10
 s011,,)<,	, , , 21, s//   0/ s011)<   21 s011)<	   21 s78800)C0	0 0 0 980 s566..)A.	. . . 76. s//,6 ,6 ,6 0/,6^ s233)>	   43 s344)?	   54& s/00);	   10 s/00);	   10  r   