AlkantarClanX12

Your IP : 18.117.70.64


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/alembic/ddl/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/alembic/ddl/__pycache__/mysql.cpython-311.pyc

�

�܋f$A��V�ddlmZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Zdd	lm
Z
d
dlmZd
dlmZd
d
lmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZddlmZddlmZddlmZddlmZddlm Z er$ddlm!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)d
dlm*Z*Gd �d!e��Z+Gd"�d#e+��Z,Gd$�d%e��Z-Gd&�d'e��Z.Gd(�d)e.��Z/e
ed*d+��e
ed*d+��e
ed*d+��e
ed*d+��d,���������Z0e
e-d*d+��dAd2���Z1e
e/d*d+��dBd3���Z2e
e.d*d+��dCd4���Z3dDd>�Z4e
e	j%d*d+��dEd@���Z5dS)F�)�annotationsN)�Any)�Optional)�
TYPE_CHECKING)�Union��schema)�types)�compiles�)�alter_table)�AlterColumn)�
ColumnDefault)�
ColumnName)�ColumnNullable)�
ColumnType)�format_column_name)�format_server_default)�DefaultImpl�)�util)�compare)�sqla_compat)�_is_mariadb)�_is_type_bound)�Literal)�MySQLDDLCompiler)�DropConstraint)�
Constraint)�
TypeEngine)�_ServerDefaultc���eZdZdZdZejddhddhfzZddgZ												d,d-�fd#�
Zd.�fd&�Z	d/d(�Z
d)�Zd*�Zd+�Z
�xZS)0�	MySQLImpl�mysqlF�BOOL�TINYINT�JSON�LONGTEXTzcharacter set ([\w\-_]+)zcollate ([\w\-_]+)N�
table_name�str�column_name�nullable�Optional[bool]�server_default�%Union[_ServerDefault, Literal[False]]�name�
Optional[str]�type_�Optional[TypeEngine]r	�
existing_type�existing_server_default�Optional[_ServerDefault]�existing_nullable�
autoincrement�existing_autoincrement�comment�$Optional[Union[str, Literal[False]]]�existing_comment�kwr�return�Nonec�z��tj||	��stj||	��r#t��j||f|||||
||	d�|��|�|�|�|n||��rM|�t||||�|n||�|n|
�|
nd|�|n||dur|n|	|�|n||
dur|
n|��	�	��dS|�|�|�|
durM|�t||||�|n||�|n|
�|
nd|�|n||dur|n|	|�|n||
dur|
n|��	�	��dS|dur(|�t||||�����dSdS)N)r,r2r	r4r7r.r5TF)r	�newnamer,r2�defaultr8r:r)
r�_server_default_is_identity�_server_default_is_computed�super�alter_column�$_is_mysql_allowed_functional_default�_exec�MySQLChangeColumn�MySQLModifyColumn�MySQLAlterDefault)�selfr)r+r,r.r0r2r	r4r5r7r8r9r:r<r=�	__class__s                ��H/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/ddl/mysql.pyrFzMySQLImpl.alter_column1s���$�2��3�
�
�	�
�
4��3�
�
�	�
!�E�G�G� ���
�"���+�"3�-�(?�
�
��
�
�
���t�H�H��&�E�E�M�>� 
� 
��
�J�J�!���!�$(�$4�D�D�+��+�&�X�)�4�+�*��#(�#4�%�%�-�%�U�2�2�+�N�0�$�0�#0�-�/��e�+�+�$�G�)�'���
�
�
�
�
�0
� �� ��(��e�#�#��J�J�!���!�$(�$4�D�D�+��+�&�X�)�4�+�*��#(�#4�%�%�-�%�U�2�2�+�N�0�$�0�#0�-�/��e�+�+�$�G�)�'���
�
�
�
�
�.�5�
(�
(��J�J�!���^�F����
�
�
�
�
�)�
(��constrc���t|tj��rt|��rdSt	���|��dS�N)�
isinstancer	�CheckConstraintrrE�drop_constraint)rLrPrMs  �rNrUzMySQLImpl.drop_constraint�sL����e�V�3�4�4�	���9N�9N�	��F�
������&�&�&�&�&rO�boolc�8�|duo|jtjuo|duSrR)�_type_affinity�sqltypes�DateTime)rLr2r.s   rNrGz.MySQLImpl._is_mysql_allowed_functional_default�s6��
���
+��$�� �!�
+��d�*�		
rOc�\�|jjtjur|jr|js
|s|dkrdS|r8|jjtjur |�t
jdd|��nd}||kS|r8|jjtjur t
jdd|��}|d|�d�kS|�r|r�t
j	d|�
����}t
j	d|�
����}|r\|sdS|�d��|�d��krdS|�d	��}|�d	��}t
jd
d|�
����t
jd
d|�
����kS||kS)Nz'0'Fz^'|'$��'z(.*) (on update.*?)(?:\(\))?$Trrz(.*?)(?:\(\))?$z\1)�typerXrY�Integer�primary_keyr8�re�sub�String�match�lower�group)rL�inspector_column�metadata_column�rendered_metadata_default�rendered_inspector_default�metadata_default�onupdate_ins�onupdate_mets        rN�compare_server_defaultz MySQLImpl.compare_server_default�s��
� �/�8�3C�C�C� �,�
D�$�2�
D�.�
D�+�e�3�3��5�&�.	K� �%�4��8H�H�H�.�9���x��%?�@�@�@��
'�
.�1J�J�J�%�$	K��$�3�x��F�F�!�v�h��4M�N�N��-�1H�5E�1H�1H�1H�H�H�
'�	K�,E�	K��8�0�*�0�0�2�2���L��8�0�)�/�/�1�1���L�
�
B�#� ��4�!�'�'��*�*�l�.@�.@��.C�.C�C�C��4�-9�-?�-?��-B�-B�*�,8�,>�,>�q�,A�,A�)��6�"�E�+E�+K�+K�+M�+M�����"�E�+D�+J�+J�+L�+L����
�.�1J�J�JrOc��t��}t|��D]�}|jr�
|jD]�}|j|jkr1|�|��|�|j��nW|jD]C}|j|jkr1|�|��|�|j��n�D|j|vrn����t|��D] }|j|vr|�|���!dSrR)�set�list�unique�columnsr0�remove�add�foreign_keys)	rL�conn_unique_constraints�conn_indexes�metadata_unique_constraints�metadata_indexes�removed�idx�col�fks	         rN�correct_for_autogen_constraintsz)MySQLImpl.correct_for_autogen_constraints�s3���%�%����%�%�	�	�C��z�
��
�{�
�
���8�s�x�'�'� �'�'��,�,�,��K�K���)�)�)��E��*���B��w�#�(�*�*�$�+�+�C�0�0�0����C�H�-�-�-���+��8�w�&�&��E�'���(�)�)�	-�	-�C��x�7�"�"� �'�'��,�,�,��	-�	-rOc�h�d�|D��}d�|D��}t|���|��D]v}||}||}|j�+|j���dkr|j�d|_|j�+|j���dkr|j�d|_�wdS)Nc�B�i|]}tj|��j|��S��r�_fk_constraint_sig�sig��.0r~s  rN�
<dictcomp>z=MySQLImpl.correct_for_autogen_foreignkeys.<locals>.<dictcomp>s5��
�
�
�79�G�&�r�*�*�.��
�
�
rOc�B�i|]}tj|��j|��Sr�r�r�s  rNr�z=MySQLImpl.correct_for_autogen_foreignkeys.<locals>.<dictcomp>s5��
�
�
�79�G�&�r�*�*�.��
�
�
rO�restrict�RESTRICT)rp�intersection�ondeletere�onupdate)rL�conn_fks�metadata_fks�conn_fk_by_sig�metadata_fk_by_sigr��mdfk�cnfks        rN�correct_for_autogen_foreignkeysz)MySQLImpl.correct_for_autogen_foreignkeyss���
�
�=E�
�
�
��
�
�=I�
�
�
���~�&�&�3�3�4F�G�G�	+�	+�C�%�c�*�D�!�#�&�D�
�
�)��M�'�'�)�)�Z�7�7��M�)� *��
��
�)��M�'�'�)�)�Z�7�7��M�)� *��
��#	+�	+rO)NFNNNNNNNNFN) r)r*r+r*r,r-r.r/r0r1r2r3r	r1r4r3r5r6r7r-r8r-r9r-r:r;r<r1r=rr>r?)rPrr>r?)r2r3r.r/r>rV)�__name__�
__module__�__qualname__�__dialect__�transactional_ddlr�
type_synonyms�type_arg_extractrFrUrGrnrr��
__classcell__�rMs@rNr#r#'s��������K����-�	���	���1��M�4�5J�K��$(�@E�"�&*� $�.2�<@�,0�(,�15�8=�*.�a�a�a�a�a�a�a�F'�'�'�'�'�'�

�

�

�

�AK�AK�AK�F$-�$-�$-�L+�+�+�+�+�+�+rOr#c��eZdZdZdS)�MariaDBImpl�mariadbN)r�r�r�r�r�rOrNr�r�.s�������K�K�KrOr�c�$��eZdZ	dd
�fd�
Z�xZS)rKNr0r*r+rBr!r	r1r>r?c�x��tt|���||���||_||_dS)Nr)rEr�__init__r+rB)rLr0r+rBr	rMs     �rNr�zMySQLAlterDefault.__init__3s;���	�k�4� � �)�)�$�v�)�>�>�>�&�������rOrR)
r0r*r+r*rBr!r	r1r>r?�r�r�r�r�r�r�s@rNrKrK2sG�������!%�	�	�	�	�	�	�	�	�	�	�	rOrKc�0��eZdZ							dd�fd�
Z�xZS)rINFr0r*r+r	r1rAr2r3r,r-rB�/Optional[Union[_ServerDefault, Literal[False]]]r8r:r;r>r?c
���tt|���||���||_||_||_||_||_|	|_|�tj
d���tj|��|_
dS)NrzDAll MySQL CHANGE/MODIFY COLUMN operations require the existing type.)rErr�r+r,rArBr8r:r�CommandErrorrY�to_instancer2)rLr0r+r	rAr2r,rBr8r:rMs          �rNr�zMySQLChangeColumn.__init__@s����	�k�4� � �)�)�$�v�)�>�>�>�&��� ��
�������*�������=��#�-���
�
�)�%�0�0��
�
�
rO)NNNNFNF)r0r*r+r*r	r1rAr1r2r3r,r-rBr�r8r-r:r;r>r?r�r�s@rNrIrI?sY�������
!%�!%�&*�#'�CH�(,�8=�1�1�1�1�1�1�1�1�1�1�1rOrIc��eZdZdS)rJN)r�r�r�r�rOrNrJrJ\s�������DrOrJr$r�c� �td���)Nz9Individual alter column constructs not supported by MySQL)�NotImplementedError��element�compilerr=s   rN� _mysql_doesnt_support_individualr�`s��
�C���rOr�r�rr>r*c	��t||j|j���dt||j���d|j�dt
||j��znd��S)Nz ALTER COLUMN � zSET DEFAULT %szDROP DEFAULT)r
r)r	rr+rBrr�s   rN�_mysql_alter_defaultr�jsh��
	�H�g�0�'�.�A�A�A�A��8�W�%8�9�9�9�9��?�&�	�0��7�?�K�K�K�K�
�	��rOc���t||j|j���dt||j���dt||j|j|j|j	|j
�����S)Nz MODIFY r��r,r.r2r8r:)r
r)r	rr+�_mysql_colspecr,rBr2r8r:r�s   rN�_mysql_modify_columnr�wss��
	�H�g�0�'�.�A�A�A�A��8�W�%8�9�9�9�9����%�"�?��-�!�/��O�
	
�	
�	
�	
��rOc���t||j|j���dt||j���dt||j���dt
||j|j|j	|j
|j�����S)Nz CHANGE r�r�)r
r)r	rr+rAr�r,rBr2r8r:r�s   rN�_mysql_change_columnr��s���
	�H�g�0�'�.�A�A�A�A��8�W�%8�9�9�9�9��8�W�_�5�5�5�5����%�"�?��-�!�/��O�
	
�	
�	
�	
�	�rOr,r-r.r�r2r r8r:r;c��|jj�|���d|rdnd��}|r|dz
}|dur|�|dt||��zz
}|r2|d|j�|t
j����zz
}|S)Nr��NULLzNOT NULLz AUTO_INCREMENTFz DEFAULT %sz COMMENT %s)�dialect�
type_compiler�processr�sql_compiler�render_literal_valuerYrc)r�r,r.r2r8r:�specs       rNr�r��s���	��&�.�.�u�5�5�5�5��*���
�*��D��"��!�!���U�"�"�~�'A��
� 5�h�� O� O�O�O���
��
�� 5� J� J��X�_�&�&�!
�!
�
�	
���KrOrc��|j}t|tjtjtjf��r|rJ�|�|��St|tj��r�t|j	��r=d|j
�|j���d|j
�
|����Sd|j
�|j���d|j
�
|����Std���)zVRedefine SQLAlchemy's drop constraint to
    raise errors for invalid constraint type.zALTER TABLE z DROP CONSTRAINT z DROP CHECK zFNo generic 'DROP CONSTRAINT' in MySQL - please specify constraint type)r�rSr	�ForeignKeyConstraint�PrimaryKeyConstraint�UniqueConstraint�visit_drop_constraintrTrr��preparer�format_table�table�format_constraintr�)r�r�r=�
constraints    rN�_mysql_drop_constraintr��s!����J����'��'��#�	
���
��
�
�v��-�-�g�6�6�6�	�J�� 6�	7�	7�
��x�'�(�(�		�		��!�.�.�z�/?�@�@�@�@��!�3�3�J�?�?�?��
�		��!�.�.�z�/?�@�@�@�@��!�3�3�J�?�?�?��
�
"�
-�
�
�	
rO)r�rKr�rr>r*)r�rJr�rr>r*)r�rIr�rr>r*)r�rr,r-r.r�r2r r8r-r:r;r>r*)r�rr�rr>r*)6�
__future__rra�typingrrrr�
sqlalchemyr	r
rY�sqlalchemy.ext.compilerr�baser
rrrrrrr�implrr\r�autogeneraterr�util.sqla_compatrrr�sqlalchemy.dialects.mysql.baser�sqlalchemy.sql.ddlr�sqlalchemy.sql.schemar�sqlalchemy.sql.type_apir r!r#r�rKrIrJr�r�r�r�r�r�r�rOrN�<module>r�s?��"�"�"�"�"�"�	�	�	�	������������� � � � � � �������������(�(�(�(�(�(�,�,�,�,�,�,������������������������� � � � � � �������$�$�$�$�$�$�'�'�'�'�'�'�������������"�"�"�"�"�"�������*�*�*�*�*�*�-�-�-�-�-�-��%�������?�?�?�?�?�?�1�1�1�1�1�1�0�0�0�0�0�0�2�2�2�2�2�2�$�$�$�$�$�$�D+�D+�D+�D+�D+��D+�D+�D+�N�����)����
�
�
�
�
��
�
�
�1�1�1�1�1��1�1�1�:	�	�	�	�	�)�	�	�	�
��.�'�9�-�-�	��*�g�y�)�)�	��-��)�,�,�	��*�g�y�)�)���*�)�-�,�*�)�.�-��
��
�W�i�0�0�	�	�	�1�0�	�
��
�W�i�0�0����1�0��"
��
�W�i�0�0����1�0��$����0
��&�
��)�4�4�#
�#
�#
�5�4�#
�#
�#
rO