� J�g�r� �� �ddlmZddlmZddlZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZer�ddlmZddl m!Z!ddl"m#Z#ddl"m$Z$dd l"m%Z%dd!l"m&Z&dd"l'm(Z(dd#l)m*Z*dd$l)m+Z+dd%l)m,Z,dd&l)m-Z-dd'l)m.Z.dd(l)m/Z/dd)l)m0Z0dd*l)m1Z1dd+l)m2Z2dd,l)m3Z3dd-l)m4Z4dd.l)m5Z5dd/l6m7Z7dd0l8m9Z9dd1l:m;Z;dd2l<m=Z=dd3l>m?Z?ed4e�5��Z@ed6d7�5��ZAGd8�d9��ZBGd:�d7eB��ZCejDd;��ejDd;d<��Gd=�d>eB������ZEejDd?��ejDd?d@��eC�FdA��GdB�dCeC��������ZGejDdD��ejDdDdE��eC�FdF��GdG�dHeC��������ZHejDdI��ejDdIdJ��eC�FdK��GdL�dMeC��������ZIejDdN��ejDdNdO��eC�FdP��eC�FdQ��eC�FdR��GdS�dTeC������������ZJejDdU��ejDdUdV��GdW�dXeB������ZKejDdY��ejDdYdZ��Gd[�d\eB������ZLejDd]��Gd^�d_eB����ZMejDd`��Gda�dbeB����ZNGdc�ddeB��ZOejDde��Gdf�dgeO����ZPejDdh��ejDdhdi��Gdj�dkeO������ZQejDdl��ejDdldm��Gdn�doeO������ZRejDdp��ejDdpdq��Gdr�dseO������ZSejDdt��ejDdtdu��Gdv�dweO������ZTejDdx��ejDdxdy��Gdz�d{eO������ZUejDd|��Gd}�d~eB����ZVejDd��ejDdd���Gd��d�eB������ZWGd��d�eB��ZXGd��d�eX��ZYGd��d�eX��ZZGd��d�eX��Z[Gd��d�eB��Z\dS)��)� annotations)�abstractmethodN)�Any)�Callable)�cast)�Dict)� FrozenSet)�Iterator)�List)�MutableMapping)�Optional)�Sequence)�Set)�Tuple)�Type)� TYPE_CHECKING)�TypeVar)�Union)�NULLTYPE�)� schemaobj)�BatchOperations)� Operations�)�util)� sqla_compat)�Literal)� Executable)� ColumnElement)�conv)� quoted_name)� TextClause)�Function)�CheckConstraint)�Column)�Computed)� Constraint)�ForeignKeyConstraint)�Identity)�Index)�MetaData)�PrimaryKeyConstraint)� SchemaItem)�Table)�UniqueConstraint)� TableClause)� TypeEngine)�Rewriter)�MigrationContext)� _RevIdType�_T)�bound�_AC�AddConstraintOpc�d�eZdZUdZejd d���Ze��Zde d<d d�Z d d �Z d S)�MigrateOperationz�base class for migration command and organization objects. This system is part of the operation extensibility API. .. seealso:: :ref:`operation_objects` :ref:`operation_plugins` :ref:`customizing_revision` �return�Dict[Any, Any]c��iS)z�A dictionary that may be used to store arbitrary information along with this :class:`.MigrateOperation` object. ���selfs �f/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/alembic/operations/ops.py�infozMigrateOperation.infoMs �� � �zFrozenSet[Rewriter]� _mutationsc��t��N��NotImplementedErrorr?s rA�reversezMigrateOperation.reverseW���!�!rC�Tuple[Any, ...]c��t�rFrGr?s rA� to_diff_tuplezMigrateOperation.to_diff_tupleZrJrCN)r;r<)r;r:�r;rK) �__name__� __module__� __qualname__�__doc__r�memoized_propertyrB� frozensetrD�__annotations__rIrMr>rCrAr:r:>s�������� � � ��������'0�i�k�k�J�1�1�1�1�"�"�"�"�"�"�"�"�"�"rCr:c��eZdZdZej��Zedd���Ze dd���Z e dd ���Z e ddd���Z dd�Zdd�Zd S)r8z&Represent an add constraint operation.r;�strc��t���rFrGr?s rA�constraint_typezAddConstraintOp.constraint_typecs��!�#�#�#rC�type_� Callable[[Type[_AC]], Type[_AC]]c����d��fd� }|S)N�klass� Type[_AC]r;c�X���j����|j��|SrF)�add_constraint_ops� dispatch_for�from_constraint)r]�clsrZs ��rA�goz3AddConstraintOp.register_add_constraint.<locals>.goks,��� 6�C� "� /� /�� 6� 6�u�7L� M� M� M��LrC)r]r^r;r^r>)rcrZrds`` rA�register_add_constraintz'AddConstraintOp.register_add_constraintgs.���� � � � � � � �� rC� constraintr'c�R�|j�|j��|��SrF)r`�dispatch�__visit_name__)rcrfs rArbzAddConstraintOp.from_constraintqs-��I�s�%�.�.�z�/H�I�I� � � � rCN�migration_context�Optional[MigrationContext]c��dSrFr>)r@rjs rA� to_constraintzAddConstraintOp.to_constraintws �� �rC�DropConstraintOpc�Z�t�|�����SrF)rnrbrmr?s rArIzAddConstraintOp.reverse}s"���/�/��0B�0B�0D�0D�E�E�ErC�Tuple[str, Constraint]c�.�d|���fS)N�add_constraint�rmr?s rArMzAddConstraintOp.to_diff_tuple�s�� �$�"4�"4�"6�"6�7�7rC)r;rW)rZrWr;r[)rfr'r;r8rF)rjrkr;r')r;rn)r;rp)rOrPrQrRr� Dispatcherr`�propertyrY� classmethodrerbrrmrIrMr>rCrAr8r8^s�������0�0�(���*�*�� �$�$�$��X�$������[��� � � ��[� � �>B� � � � ��^� � F�F�F�F�8�8�8�8�8�8rC�drop_constraint�batch_drop_constraintc��eZdZdZ dddd�dd�Zd d�Zd!d�Zed"d���Zd#d�Z e ddd�d$d���Z e dd%d���Z dS)&rnz&Represent a drop constraint operation.N��schema�_reverse�constraint_name�,Optional[sqla_compat._ConstraintNameDefined]� table_namerWrZ� Optional[str]r{r|�Optional[AddConstraintOp]r;�Nonec�L�||_||_||_||_||_dSrF)r}rrYr{r|)r@r}rrZr{r|s rA�__init__zDropConstraintOp.__init__�s-�� /���$���$����� � �� � � rCr8c�Z�t�|�����SrF)r8rbrmr?s rArIzDropConstraintOp.reverse�s"���.�.�t�/A�/A�/C�/C�D�D�DrC�Tuple[str, SchemaItem]c�p�|jdkrd|���fSd|���fS)N� foreignkey� remove_fk�remove_constraint)rYrmr?s rArMzDropConstraintOp.to_diff_tuple�s@�� � �<� /� /���!3�!3�!5�!5�6� 6�'��);�);�)=�)=�>� >rCrfr'c ���ddddddd�}tj|��}|tj|j��|j|j|�|j��t�|�����S)N�uniquer��primary�check)�unique_constraint�foreign_key_constraint�primary_key_constraint�check_constraint�column_check_constraint� table_or_column_check_constraint)r{rZr|) r�_table_for_constraint�constraint_name_or_none�namer{�getrir8rb)rcrf�types�constraint_tables rArbz DropConstraintOp.from_constraint�s���"*�&2�&/� '�'.�07�  � ��'�<�Z�H�H���s� � /� �� @� @� � !�#�*��)�)�J�5�6�6�$�4�4�Z�@�@�  � � � rCc���|j�S|j���}|j|_t j|��}|j|_|j|_|Std���)NzAconstraint cannot be produced; original constraint is not present) r|rmr}r�rr�rr{� ValueError)r@rfr�s rArmzDropConstraintOp.to_constraint�sk�� �=� $���4�4�6�6�J�"�2�J�O�*�@��L�L� �$(�O� � !�&*�k� � #�� ��5��� rC�r{� operationsrc�J�|||||���}|�|��S)a Drop a constraint of the given name, typically via DROP CONSTRAINT. :param constraint_name: name of the constraint. :param table_name: table name. :param type\_: optional, required on MySQL. can be 'foreignkey', 'primary', 'unique', or 'check'. :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. �rZr{��invoke)rcr�r}rrZr{�ops rArwz DropConstraintOp.drop_constraint�s0��.�S��*�E�&� I� I� I��� � ��$�$�$rCrc�r�|||jj||jj���}|�|��S)aIssue a "drop constraint" instruction using the current batch migration context. The batch form of this call omits the ``table_name`` and ``schema`` arguments from the call. .. seealso:: :meth:`.Operations.drop_constraint` r���implrr{r�)rcr�r}rZr�s rArxz&DropConstraintOp.batch_drop_constraint�sF��$�S� � �O� &���?�)�  � � �� � � ��$�$�$rCrF) r}r~rrWrZr�r{r�r|r�r;r�)r;r8)r;r�)rfr'r;rn)r;r') r�rr}rWrrWrZr�r{r�r;r�)r�rr}rWrZr�r;r�) rOrPrQrRr�rIrMrvrbrmrwrxr>rCrArnrn�s������1�0� $� !� !%�.2� !� !� !� !� !� !�E�E�E�E�?�?�?�?�� � � ��[� �& � � � �� $� %�!%�%�%�%�%�%��[�%�2� $� %�%�%�%��[�%�%�%rCrn�create_primary_key�batch_create_primary_keyr�c�~�eZdZdZdZdd�dd�Zed d���Z d!d"d�Zedd�d#d���Z ed$d���Z dS)%�CreatePrimaryKeyOpz)Represent a create primary key operation.� primarykeyNr�r}r~rrW�columns� Sequence[str]r{r��kwrr;r�c �L�||_||_||_||_||_dSrF�r}rr�r{r��r@r}rr�r{r�s rAr�zCreatePrimaryKeyOp.__init__�,�� /���$����� ��� �����rCrfr'c���tj|��}td|��}|tj|j��|j|j���fd|ji|j��S)Nr,r{) rr�rr�r�r��keysr{�dialect_kwargs)rcrfr�� pk_constraints rArbz"CreatePrimaryKeyOp.from_constraints��&�<�Z�H�H���3�Z�@�@� ��s� � /� �0B� C� C� � !� � !� &� &� (� (� � �$�*�  � �*�  � � rCrjrkr,c��tj|��}|j|j|j|jfd|ji|j��S�Nr{)r� SchemaObjectsr�r}rr�r{r��r@rj� schema_objs rArmz CreatePrimaryKeyOp.to_constraint sY���,�->�?�?� �0�z�0� � � �O� �L� � ��;�  � �g�  � � rCr�r� List[str]c�J�|||||���}|�|��S)a"Issue a "create primary key" instruction using the current migration context. e.g.:: from alembic import op op.create_primary_key("pk_my_table", "my_table", ["id", "version"]) This internally generates a :class:`~sqlalchemy.schema.Table` object containing the necessary columns, then generates a new :class:`~sqlalchemy.schema.PrimaryKeyConstraint` object which it then associates with the :class:`~sqlalchemy.schema.Table`. Any event listeners associated with this action will be fired off normally. The :class:`~sqlalchemy.schema.AddConstraint` construct is ultimately used to generate the ALTER statement. :param constraint_name: Name of the primary key constraint. The name is necessary so that an ALTER statement can be emitted. For setups that use an automated naming scheme such as that described at :ref:`sqla:constraint_naming_conventions` ``name`` here can be ``None``, as the event listener will apply the name to the constraint object when it is associated with the table. :param table_name: String name of the target table. :param columns: a list of string column names to be applied to the primary key constraint. :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. r�r�)rcr�r}rr�r{r�s rAr�z%CreatePrimaryKeyOp.create_primary_key-s1��X�S��*�g�f� E� E� E��� � ��$�$�$rCrc�r�|||jj||jj���}|�|��S)aIssue a "create primary key" instruction using the current batch migration context. The batch form of this call omits the ``table_name`` and ``schema`` arguments from the call. .. seealso:: :meth:`.Operations.create_primary_key` r�r�)rcr�r}r�r�s rAr�z+CreatePrimaryKeyOp.batch_create_primary_key\sF��$�S� � �O� &� ��?�)�  � � �� � � ��$�$�$rC� r}r~rrWr�r�r{r�r�rr;r�)rfr'r;r�rF)rjrkr;r,) r�rr}r�rrWr�r�r{r�r;r�)r�rr}r�r�r�r;r�) rOrPrQrRrYr�rvrbrmr�r�r>rCrAr�r��s������� 4�3�"�O�!%� � � � � � ��  �  �  ��[�  �?C�  �  �  �  �  ��!%�,%�,%�,%�,%�,%��[�,%�\�%�%�%��[�%�%�%rCr��create_unique_constraint�batch_create_unique_constraintr�c�~�eZdZdZdZdd�dd�Zedd���Z d d!d�Zedd�d"d���Z ed#d���Z dS)$�CreateUniqueConstraintOpz/Represent a create unique constraint operation.r�Nr�r}r~rrWr�r�r{r�r�rr;r�c �L�||_||_||_||_||_dSrFr�r�s rAr�z!CreateUniqueConstraintOp.__init__�r�rCrfr'c�@�tj|��}td|��}i}|jr |j|d<|jr |j|d<|�|j��|tj|j��|jd�|j D��fd|j i|��S)Nr/� deferrable� initiallyc��g|] }|j�� Sr>)r�)�.0�cs rA� <listcomp>z<CreateUniqueConstraintOp.from_constraint.<locals>.<listcomp>�s�� 3� 3� 3��Q�V� 3� 3� 3rCr{) rr�rr�r��updater�r�r�r�r{)rcrfr�� uq_constraintr�s rArbz(CreateUniqueConstraintOp.from_constraint�s���'�<�Z�H�H���/��<�<� ��� � #� 8�,�7�B�|� � � "� 6�+�5�B�{�O� � � �-�.�/�/�/��s� � /� �0B� C� C� � !� 3� 3�]�2� 3� 3� 3� � �$�*�  � �  � � rCrjrkr/c��tj|��}|j|j|j|jfd|ji|j��Sr�)rr�r�r}rr�r{r�r�s rArmz&CreateUniqueConstraintOp.to_constraint�sY���,�->�?�?� �+�z�+� � � �O� �L� � ��;�  � �g�  � � rCr�rc �F�||||fd|i|��}|�|��S)a�Issue a "create unique constraint" instruction using the current migration context. e.g.:: from alembic import op op.create_unique_constraint("uq_user_name", "user", ["name"]) This internally generates a :class:`~sqlalchemy.schema.Table` object containing the necessary columns, then generates a new :class:`~sqlalchemy.schema.UniqueConstraint` object which it then associates with the :class:`~sqlalchemy.schema.Table`. Any event listeners associated with this action will be fired off normally. The :class:`~sqlalchemy.schema.AddConstraint` construct is ultimately used to generate the ALTER statement. :param name: Name of the unique constraint. The name is necessary so that an ALTER statement can be emitted. For setups that use an automated naming scheme such as that described at :ref:`sqla:constraint_naming_conventions`, ``name`` here can be ``None``, as the event listener will apply the name to the constraint object when it is associated with the table. :param table_name: String name of the source table. :param columns: a list of string column names in the source table. :param deferrable: optional bool. If set, emit DEFERRABLE or NOT DEFERRABLE when issuing DDL for this constraint. :param initially: optional string. If set, emit INITIALLY <value> when issuing DDL for this constraint. :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. r{r�)rcr�r}rr�r{r�r�s rAr�z1CreateUniqueConstraintOp.create_unique_constraint�s9��b�S��*�g� K� K�f� K�� K� K��� � ��$�$�$rCrc �t�|jj|d<|||jj|fi|��}|�|��S)a%Issue a "create unique constraint" instruction using the current batch migration context. The batch form of this call omits the ``source`` and ``schema`` arguments from the call. .. seealso:: :meth:`.Operations.create_unique_constraint` r{)r�r{rr�)rcr�r}r�r�r�s rAr�z7CreateUniqueConstraintOp.batch_create_unique_constraint�sF��&"��-��8� � �S��*�/�"<�g� L� L�� L� L��� � ��$�$�$rCr�)rfr'r;r�rF)rjrkr;r/)r�rr}r�rrWr�r�r{r�r�rr;r) r�rr}rWr�r�r�rr;r) rOrPrQrRrYr�rvrbrmr�r�r>rCrAr�r�ws������� :�9��O�!%� � � � � � �� � � ��[� �,?C�  �  �  �  �  ��!%�1%�1%�1%�1%�1%��[�1%�f�%�%�%��[�%�%�%rCr��create_foreign_key�batch_create_foreign_keyr�c ��eZdZdZdZd+d�Zd,d�Zed-d���Z d.d/d�Z edddddddd�d0d'���Z eddddddd(�d1d*���Z dS)2�CreateForeignKeyOpz4Represent a create foreign key constraint operation.r�r}r~� source_tablerW�referent_table� local_colsr�� remote_colsr�rr;r�c �Z�||_||_||_||_||_||_dSrF)r}r�r�r�r�r�)r@r}r�r�r�r�r�s rAr�zCreateForeignKeyOp.__init__s6�� /���(���,���$���&�������rC� Tuple[str, ForeignKeyConstraint]c�.�d|���fS)N�add_fkrsr?s rArMz CreateForeignKeyOp.to_diff_tuples���$�,�,�.�.�/�/rCrfr'c ���td|��}i}|jr |j|d<|jr |j|d<|jr |j|d<|jr |j|d<|jr |j|d<|jr |j|d<tj|��\ }}}}}} } } } } ||d<||d <|� |j ��|tj |j ��|||| fi|��S) Nr(�onupdate�ondeleter�r�� use_alter�match� source_schema�referent_schema) rr�r�r�r�r�r�r�_fk_specr�r�r�r�)rcrf� fk_constraintr�r�r��source_columns� target_schema� target_table�target_columnsr�r�r�r�s rArbz"CreateForeignKeyOp.from_constraintsA���3�Z�@�@� ��� � !� 4�*�3�B�z�N� � !� 4�*�3�B�z�N� � "� 6�+�5�B�{�O� � #� 8�,�7�B�|� � � "� 6�+�5�B�{�O� � � .�'�-�B�w�K� � �� /� /� � � � � � � � � � � �,��?�� -�� �� � � �-�.�/�/�/��s� � /� �0B� C� C� � � � �  � � �  � � rCNrjrkr(c��tj|��}|j|j|j|j|j|jfi|j��SrF) rr�r�r}r�r�r�r�r�r�s rArmz CreateForeignKeyOp.to_constraintEsZ���,�->�?�?� �0�z�0� � � � � � � �O� � �  � � �g�  � � rC)r�r�r�r�r�r�r�r�rr�r�r�r��Optional[bool]r�r�r�r�� dialect_kwc �V�||||||f||| | | | | d�|��}|�|��S)a�Issue a "create foreign key" instruction using the current migration context. e.g.:: from alembic import op op.create_foreign_key( "fk_user_address", "address", "user", ["user_id"], ["id"], ) This internally generates a :class:`~sqlalchemy.schema.Table` object containing the necessary columns, then generates a new :class:`~sqlalchemy.schema.ForeignKeyConstraint` object which it then associates with the :class:`~sqlalchemy.schema.Table`. Any event listeners associated with this action will be fired off normally. The :class:`~sqlalchemy.schema.AddConstraint` construct is ultimately used to generate the ALTER statement. :param constraint_name: Name of the foreign key constraint. The name is necessary so that an ALTER statement can be emitted. For setups that use an automated naming scheme such as that described at :ref:`sqla:constraint_naming_conventions`, ``name`` here can be ``None``, as the event listener will apply the name to the constraint object when it is associated with the table. :param source_table: String name of the source table. :param referent_table: String name of the destination table. :param local_cols: a list of string column names in the source table. :param remote_cols: a list of string column names in the remote table. :param onupdate: Optional string. If set, emit ON UPDATE <value> when issuing DDL for this constraint. Typical values include CASCADE, DELETE and RESTRICT. :param ondelete: Optional string. If set, emit ON DELETE <value> when issuing DDL for this constraint. Typical values include CASCADE, DELETE and RESTRICT. :param deferrable: optional bool. If set, emit DEFERRABLE or NOT DEFERRABLE when issuing DDL for this constraint. :param source_schema: Optional schema name of the source table. :param referent_schema: Optional schema name of the destination table. �r�r�r�r�r�r�r�r�)rcr�r}r�r�r�r�r�r�r�r�r�r�r�r�r�s rAr�z%CreateForeignKeyOp.create_foreign_keyRsf��J�S� � � � � �  � ��!�'�+��� � �� � ��� � ��$�$�$rC)r�r�r�r�r�r�rc �~�|||jj|||f||| |jj|| | d�| ��} |�| ��S)a+Issue a "create foreign key" instruction using the current batch migration context. The batch form of this call omits the ``source`` and ``source_schema`` arguments from the call. e.g.:: with batch_alter_table("address") as batch_op: batch_op.create_foreign_key( "fk_user_address", "user", ["user_id"], ["id"], ) .. seealso:: :meth:`.Operations.create_foreign_key` r�r�)rcr�r}r�r�r�r�r�r�r�r�r�r�r�s rAr�z+CreateForeignKeyOp.batch_create_foreign_key�sp��L�S� � �O� &� � � �  � ��!�$�/�0�+��� � �� � ��� � ��$�$�$rC)r}r~r�rWr�rWr�r�r�r�r�rr;r�)r;r�)rfr'r;r�rF)rjrkr;r()r�rr}r�r�rWr�rWr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr;r�)r�rr}r�r�rWr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr;r�) rOrPrQrRrYr�rMrvrbrmr�r�r>rCrAr�r��s������ ?�>�"�O����� 0�0�0�0��' �' �' ��[�' �T?C�  �  �  �  �  ��#'�"&�%)�#'�#�'+�)-�S%�S%�S%�S%�S%��[�S%�j�*.�"&�"&�%)�#'�#�4%�4%�4%�4%�4%��[�4%�4%�4%rCr��create_check_constraint�batch_create_check_constraintr�r�r�c�~�eZdZdZdZdd�dd�Zed d���Z d!d"d�Zedd�d#d���Z ed$d���Z dS)%�CreateCheckConstraintOpz.Represent a create check constraint operation.r�Nr�r}r~rrW� condition�*Union[str, TextClause, ColumnElement[Any]]r{r�r�rr;r�c �L�||_||_||_||_||_dSrF)r}rr�r{r�)r@r}rr�r{r�s rAr�z CreateCheckConstraintOp.__init__�s,�� /���$���"����� �����rCrfr'c���tj|��}td|��}|tj|j��|jtd|j��fd|ji|j��S)Nr$zColumnElement[Any]r{)rr�rr�r��sqltextr{r�)rcrfr�� ck_constraints rArbz'CreateCheckConstraintOp.from_constraint�s���'�<�Z�H�H���.� �;�;� ��s� � /� �0B� C� C� � !� �%�}�'<� =� =� � �$�*�  � �*�  � � rCrjrkr$c��tj|��}|j|j|j|jfd|ji|j��Sr�)rr�r�r}rr�r{r�r�s rArmz%CreateCheckConstraintOp.to_constraint sY���,�->�?�?� �*�z�*� � � �O� �N� � ��;�  � �g�  � � rCr�r�+Union[str, ColumnElement[bool], TextClause]c �F�||||fd|i|��}|�|��S)aIssue a "create check constraint" instruction using the current migration context. e.g.:: from alembic import op from sqlalchemy.sql import column, func op.create_check_constraint( "ck_user_name_len", "user", func.len(column("name")) > 5, ) CHECK constraints are usually against a SQL expression, so ad-hoc table metadata is usually needed. The function will convert the given arguments into a :class:`sqlalchemy.schema.CheckConstraint` bound to an anonymous table in order to emit the CREATE statement. :param name: Name of the check constraint. The name is necessary so that an ALTER statement can be emitted. For setups that use an automated naming scheme such as that described at :ref:`sqla:constraint_naming_conventions`, ``name`` here can be ``None``, as the event listener will apply the name to the constraint object when it is associated with the table. :param table_name: String name of the source table. :param condition: SQL expression that's the condition of the constraint. Can be a string or SQLAlchemy expression language structure. :param deferrable: optional bool. If set, emit DEFERRABLE or NOT DEFERRABLE when issuing DDL for this constraint. :param initially: optional string. If set, emit INITIALLY <value> when issuing DDL for this constraint. :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. r{r�)rcr�r}rr�r{r�r�s rAr�z/CreateCheckConstraintOp.create_check_constraints9��f�S��*�i� M� M�� M�"� M� M��� � ��$�$�$rCrc �n�|||jj|fd|jji|��}|�|��S)a#Issue a "create check constraint" instruction using the current batch migration context. The batch form of this call omits the ``source`` and ``schema`` arguments from the call. .. seealso:: :meth:`.Operations.create_check_constraint` r{r�)rcr�r}r�r�r�s rAr�z5CreateCheckConstraintOp.batch_create_check_constraintLsW��&�S� � �O� &� � � ��?�)�  � �  � ��� � ��$�$�$rC) r}r~rrWr�r�r{r�r�rr;r�)rfr'r;r�rF)rjrkr;r$)r�rr}r�rrWr�r�r{r�r�rr;r�) r�rr}rWr�r�r�rr;r�) rOrPrQrRrYr�rvrbrmr�r�r>rCrAr�r��s�������9�8��O�!%� � � � � � ��  �  �  ��[�  �?C�  �  �  �  �  ��!%�3%�3%�3%�3%�3%��[�3%�j�%�%�%��[�%�%�%rCr�� create_index�batch_create_indexc��eZdZdZdddd�d&d�Zd'd�Zd(d�Zed)d���Z d*d+d�Z edddd�d,d"���Z ed-d%���Z dS).� CreateIndexOpz#Represent a create index operation.NF�r{r�� if_not_exists� index_namer�rrWr��4Sequence[Union[str, TextClause, ColumnElement[Any]]]r{r��boolrr�r�rr;r�c �h�||_||_||_||_||_||_||_dSrF)rrr�r{r�rr�)r@rrr�r{r�rr�s rAr�zCreateIndexOp.__init__ns:��%���$����� ��� ��� �*�������rC� DropIndexOpc�Z�t�|�����SrF)r� from_index�to_indexr?s rArIzCreateIndexOp.reverse�s���%�%�d�m�m�o�o�6�6�6rC�Tuple[str, Index]c�.�d|���fS)N� add_index�r r?s rArMzCreateIndexOp.to_diff_tuple�����T�]�]�_�_�-�-rC�indexr*c��|j�J�||j|jj|jf|jj|jd�|j��S�N)r{r�)�tabler�� expressionsr{r��kwargs�rcrs rAr zCreateIndexOp.from_index�s\���{�&�&�&��s� �J� �K� � � � ��;�%��<�  � � �l�  � � rCrjrkc��tj|��}|j|j|j|jf|j|jd�|j��}|Sr) rr�rrrr�r{r�r�)r@rjr��idxs rAr zCreateIndexOp.to_index�sa���,�->�?�?� ��j�� �O� �O� �L� ��;��;�  � � �g�  � ��� rCr�r�/Sequence[Union[str, TextClause, Function[Any]]]c �J�||||f|||d�|��} |�| ��S)a�Issue a "create index" instruction using the current migration context. e.g.:: from alembic import op op.create_index("ik_test", "t1", ["foo", "bar"]) Functional indexes can be produced by using the :func:`sqlalchemy.sql.expression.text` construct:: from alembic import op from sqlalchemy import text op.create_index("ik_test", "t1", [text("lower(foo)")]) :param index_name: name of the index. :param table_name: name of the owning table. :param columns: a list consisting of string column names and/or :func:`~sqlalchemy.sql.expression.text` constructs. :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. :param unique: If True, create a unique index. :param quote: Force quoting of this column's name on or off, corresponding to ``True`` or ``False``. When left at its default of ``None``, the column identifier will be quoted according to whether the name is case sensitive (identifiers with at least one upper case character are treated as case sensitive), or if it's a reserved word. This flag is only needed to force quoting of a reserved word which is not known by the SQLAlchemy dialect. :param if_not_exists: If True, adds IF NOT EXISTS operator when creating the new index. .. versionadded:: 1.12.0 :param \**kw: Additional keyword arguments not mentioned above are dialect specific, and passed in the form ``<dialectname>_<argname>``. See the documentation regarding an individual dialect at :ref:`dialect_toplevel` for detail on documented arguments. rr�) rcr�rrr�r{r�rr�r�s rAr�zCreateIndexOp.create_index�sT��x�S� � � � ���'�  � �� � ��� � ��$�$�$rCrr�c �n�|||jj|fd|jji|��}|�|��S)z�Issue a "create index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.create_index` r{r�)rcr�rr�r�r�s rAr�z CreateIndexOp.batch_create_index�sW��"�S� � �O� &� � � ��?�)�  � �  � ��� � ��$�$�$rC)rr�rrWr�rr{r�r�rrr�r�rr;r�)r;r�r;r )rr*r;rrF�rjrkr;r*)r�rrr�rrWr�rr{r�r�rrr�r�rr;r�) r�rrrWr�r�r�rr;r�) rOrPrQrRr�rIrMrvr r r�r�r>rCrArris������.�-�!%��(,�������&7�7�7�7�.�.�.�.��  �  �  ��[�  �?C� � � � � ��!%��(,�D%�D%�D%�D%�D%��[�D%�L�%�%�%��[�%�%�%rCr� drop_index�batch_drop_indexc��eZdZdZ d#dddd�d$d�Zd%d�Zd&d�Zed'd���Z d#d(d�Z e d#ddd�d)d ���Z ed*d"���Z dS)+rz!Represent a drop index operation.N)r{� if_existsr|r�Union[quoted_name, str, conv]rr�r{r"r�r|�Optional[CreateIndexOp]r�rr;r�c �Z�||_||_||_||_||_||_dSrF)rrr{r"r|r�)r@rrr{r"r|r�s rAr�zDropIndexOp.__init__ s2��%���$����� �"��� �� �����rCr c�.�d|���fS)N� remove_indexrr?s rArMzDropIndexOp.to_diff_tuple����� � ���0�0rCrc�Z�t�|�����SrF)rr r r?s rArIzDropIndexOp.reverse����'�'�� � ���8�8�8rCrr*c��|j�J�||jf|jj|jjt�|��|jd�|j��S)N)rr{r|r�)rr�r{rr r�rrs rAr zDropIndexOp.from_index se���{�&�&�&��s� �J� ��{�'��;�%�"�-�-�e�4�4��<�  � � �l�  � � rCrjrkc��tj|��}|j|j|j|jr |jjndgfd|ji|j��S)N�xr{) rr�rrrr|r�r{r�r�s rAr zDropIndexOp.to_index,sk���,�->�?�?� � �z�� �O� �O�%)�]� =�D�M� !� !��� � ��;�  � �g�  � � rC�r{r"r�rrWc �F�||f|||d�|��}|�|��S)a�Issue a "drop index" instruction using the current migration context. e.g.:: drop_index("accounts") :param index_name: name of the index. :param table_name: name of the owning table. Some backends such as Microsoft SQL Server require this. :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. :param if_exists: If True, adds IF EXISTS operator when dropping the index. .. versionadded:: 1.12.0 :param \**kw: Additional keyword arguments not mentioned above are dialect specific, and passed in the form ``<dialectname>_<argname>``. See the documentation regarding an individual dialect at :ref:`dialect_toplevel` for detail on documented arguments. )rr{r"r�)rcr�rrr{r"r�r�s rArzDropIndexOp.drop_index;sL��L�S� � �!���  � � �  � ��� � ��$�$�$rCrc �l�||f|jj|jjd�|��}|�|��S)z�Issue a "drop index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_index` �rr{r�)rcr�rr�r�s rAr zDropIndexOp.batch_drop_indexjsR���S� � �!��1��?�)� � ��  � �� � � ��$�$�$rCrF)rr#rr�r{r�r"r�r|r$r�rr;r�r)r;r)rr*r;rr)r�rrrWrr�r{r�r"r�r�rr;r�)r�rrrWr�rr;r�) rOrPrQrRr�rMrIrvr r rr r>rCrArrs������,�+� %)�� !%�$(�,0�������"1�1�1�1�9�9�9�9��  �  �  ��[�  �?C�  �  �  �  �  �� %)� ,%� !%�$(�,%�,%�,%�,%�,%��[�,%�\�%�%�%��[�%�%�%rCr� create_tablec�~�eZdZdZddddd�d&d�Zd'd�Zd(d�Zedd�d)d���Z d*d+d �Z edd!�d,d%���Z dS)-� CreateTableOpz#Represent a create table operation.NF)r{r�_namespace_metadata�_constraints_includedrrWr��Sequence[SchemaItem]r{r�rr�r5�Optional[MetaData]r6rr�rr;r�c � �||_||_||_||_|�di��|_|�dd��|_|�dd��|_||_||_ ||_ dS)NrB�comment�prefixes) rr�r{r�poprBr:r;r�r5r6)r@rr�r{rr5r6r�s rAr�zCreateTableOp.__init__�s}��%����� ��� �*����F�F�6�2�&�&�� ��v�v�i��.�.�� ����z�4�0�0�� ����#6�� �%:��"�"�"rC� DropTableOpc�h�t�|���|j���S)N�r5)r=� from_table�to_tabler5r?s rArIzCreateTableOp.reverse�s/���%�%� �M�M�O�O��1I�&� � � rC�Tuple[str, Table]c�.�d|���fS)N� add_table�rAr?s rArMzCreateTableOp.to_diff_tuple�rrCr?rr.c ���|�|j}||jt|j��t|j��zf|j|d|jt|j��t|j ��d�|j ��S)NT)r{r5r6r:rBr;) �metadatar��listr�� constraintsr{r:�dictrB� _prefixesr�rcrr5s rAr@zCreateTableOp.from_table�s��� � &�"'�.� ��s� �J� ���M�M�D��!2�3�3� 3� ��<� 3�#'��M��e�j�!�!��%�/�*�*� � ��l� � � rCrjrkc � �tj|��}|j|jg|j�R|j|jrt|j��ng|j|j r|j � ��ni|j d�|j ��S)N)r{r;r:rBr6) rr�rrr�r{r;rHr:rB�copyr6r�r�s rArAzCreateTableOp.to_table�s����,�->�?�?� ��z�� �O�  � �\�  �  ��;�,0�M�A�T�$�-�(�(�(�r��L�%)�Y�6�����!�!�!�B�"&�"<�  �  ��g�  �  � rC)rr�rr-c�D�|||fd|i|��}|�|��S)a� Issue a "create table" instruction using the current migration context. This directive receives an argument list similar to that of the traditional :class:`sqlalchemy.schema.Table` construct, but without the metadata:: from sqlalchemy import INTEGER, VARCHAR, NVARCHAR, Column from alembic import op op.create_table( "account", Column("id", INTEGER, primary_key=True), Column("name", VARCHAR(50), nullable=False), Column("description", NVARCHAR(200)), Column("timestamp", TIMESTAMP, server_default=func.now()), ) Note that :meth:`.create_table` accepts :class:`~sqlalchemy.schema.Column` constructs directly from the SQLAlchemy library. In particular, default values to be created on the database side are specified using the ``server_default`` parameter, and not ``default`` which only specifies Python-side defaults:: from alembic import op from sqlalchemy import Column, TIMESTAMP, func # specify "DEFAULT NOW" along with the "timestamp" column op.create_table( "account", Column("id", INTEGER, primary_key=True), Column("timestamp", TIMESTAMP, server_default=func.now()), ) The function also returns a newly created :class:`~sqlalchemy.schema.Table` object, corresponding to the table specification given, which is suitable for immediate SQL operations, in particular :meth:`.Operations.bulk_insert`:: from sqlalchemy import INTEGER, VARCHAR, NVARCHAR, Column from alembic import op account_table = op.create_table( "account", Column("id", INTEGER, primary_key=True), Column("name", VARCHAR(50), nullable=False), Column("description", NVARCHAR(200)), Column("timestamp", TIMESTAMP, server_default=func.now()), ) op.bulk_insert( account_table, [ {"name": "A1", "description": "account 1"}, {"name": "A2", "description": "account 2"}, ], ) :param table_name: Name of the table :param \*columns: collection of :class:`~sqlalchemy.schema.Column` objects within the table, as well as optional :class:`~sqlalchemy.schema.Constraint` objects and :class:`~.sqlalchemy.schema.Index` objects. :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. :param if_not_exists: If True, adds IF NOT EXISTS operator when creating the new table. .. versionadded:: 1.13.3 :param \**kw: Other keyword arguments are passed to the underlying :class:`sqlalchemy.schema.Table` object created for the command. :return: the :class:`~sqlalchemy.schema.Table` object corresponding to the parameters given. rr�)rcr�rrr�r�r�s rAr2zCreateTableOp.create_table�s7��t�S��W� H� H�M� H�R� H� H��� � ��$�$�$rC)rrWr�r7r{r�rr�r5r8r6rr�rr;r�)r;r=�r;rB)rr.r5r8r;r4rF�rjrkr;r.) r�rrrWr�r-rr�r�rr;r.) rOrPrQrRr�rIrMrvr@rAr2r>rCrAr4r4�s�������-�-�!%�(,�26�&+�;�;�;�;�;�;�, � � � � .�.�.�.��HL� � � � � ��[� �2?C� � � � � � � )-� Z%�Z%�Z%�Z%�Z%��[�Z%�Z%�Z%rCr4� drop_tablec��eZdZdZddddd�d$d�Zd%d�Zd&d�Zedd�d'd���Z d(d)d�Z eddd�d*d#���Z dS)+r=z!Represent a drop table operation.N)r{r"�table_kwr|rrWr{r�r"r�rT�"Optional[MutableMapping[Any, Any]]r|�Optional[CreateTableOp]r;r�c��||_||_||_|pi|_|j�dd��|_|j�dd��|_|j�dd��|_||_dS)Nr:rBr;) rr{r"rTr<r:rBr;r|)r@rr{r"rTr|s rAr�zDropTableOp.__init__-sz��%����� �"��� ��B�� ��}�(�(��D�9�9�� ��M�%�%�f�d�3�3�� �� �)�)�*�d�;�;�� � �� � � rCrBc�.�d|���fS)N� remove_tablerEr?s rArMzDropTableOp.to_diff_tuple?r(rCr4c�Z�t�|�����SrF)r4r@rAr?s rArIzDropTableOp.reverseBr*rCr?rr.r5r8c ���||j|j|jt|j��t |j��d�|j�t� ||������S)N)r:rBr;r?)r{rTr|) r�r{r:rJrBrHrKrr4r@rLs rAr@zDropTableOp.from_tableEs|���s� �J��<� �=��U�Z�(�(� ���1�1����,� � #�-�-��+>�.���  �  �  � rCrjrkc �L�|jr |jj}ng}tj|��}|j|jg|�R|j|jr|j���ni|j rt|j ��ng|j |jr |jj ndd�|j ��}|S)NF)r:rBr;r{r6)r|r�rr�rrr:rBrNr;rHr{r6rT)r@rj�cols_and_constraintsr��ts rArAzDropTableOp.to_tableWs��� �=� &�#'�=�#8� � �#%� ��,�->�?�?� � �J� � �O� � !� � ��L�%)�Y�6�����!�!�!�B�,0�M�A�T�$�-�(�(�(�r��;�7;�}�O�� �3�3�%� � ��m� � ���rCr.r�rr�rc �N�|||||���}|�|��dS)a�Issue a "drop table" instruction using the current migration context. e.g.:: drop_table("accounts") :param table_name: Name of the table :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. :param if_exists: If True, adds IF EXISTS operator when dropping the table. .. versionadded:: 1.13.3 :param \**kw: Other keyword arguments are passed to the underlying :class:`sqlalchemy.schema.Table` object created for the command. )r{r"rTNr�)rcr�rr{r"r�r�s rArRzDropTableOp.drop_tablens6��>�S��F�i�"� M� M� M�����"�����rC) rrWr{r�r"r�rTrUr|rVr;r�rP)r;r4)rr.r5r8r;r=rFrQ) r�rrrWr{r�r"r�r�rr;r�) rOrPrQrRr�rMrIrvr@rArRr>rCrAr=r=)s�������+�+� !%�$(�7;�,0�!�!�!�!�!�!�$1�1�1�1�9�9�9�9��HL� � � � � ��[� �$?C������.� !%�$(� ������[���rCr=c� �eZdZdZdd�d d �ZdS) � AlterTableOpz#Represent an alter table operation.Nr�rrWr{r�r;r�c�"�||_||_dSrFr1)r@rr{s rAr�zAlterTableOp.__init__�s�� %����� � � rC)rrWr{r�r;r�)rOrPrQrRr�r>rCrArara�s=������-�-� !%� �������rCra� rename_tablec�H��eZdZdZdd�d�fd �Zedd�dd���Z�xZS)� RenameTableOpz#Represent a rename table operation.Nr��old_table_namerW�new_table_namer{r�r;r�c�\��t���||���||_dS�Nr�)�superr�rg)r@rfrgr{� __class__s �rAr�zRenameTableOp.__init__�s0��� ��������7�7�7�,����rCr�rc�H�||||���}|�|��S)alEmit an ALTER TABLE to rename a table. :param old_table_name: old name. :param new_table_name: new name. :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. r�r�)rcr�rfrgr{r�s rArczRenameTableOp.rename_table�s.��&�S���� ?� ?� ?��� � ��$�$�$rC)rfrWrgrWr{r�r;r�) r�rrfrWrgrWr{r�r;r�)rOrPrQrRr�rvrc� __classcell__�rks@rArere�s��������-�-�!%� -�-�-�-�-�-�-�-��!%� %�%�%�%�%��[�%�%�%�%�%rCre�create_table_comment�batch_create_table_commentc�|�eZdZdZddd�dd �Zeddd �dd���Zedd�dd���Zdd�Z d d!d�Z d"d�Z dS)#�CreateTableCommentOpz)Represent a COMMENT ON `table` operation.N�r{�existing_commentrrWr:r�r{rtr;r�c�>�||_||_||_||_dSrF)rr:rtr{)r@rr:r{rts rAr�zCreateTableCommentOp.__init__�s%��%����� � 0����� � � rC�rtr{r�rc�J�|||||���}|�|��S)aQEmit a COMMENT ON operation to set the comment for a table. :param table_name: string name of the target table. :param comment: string value of the comment being registered against the specified table. :param existing_comment: String value of a comment already registered on the specified table, used within autogenerate so that the operation is reversible, but not required for direct use. .. seealso:: :meth:`.Operations.drop_table_comment` :paramref:`.Operations.alter_column.comment` rvr�)rcr�rr:rtr{r�s rAroz)CreateTableCommentOp.create_table_comment�s<��8�S� � �-��  � � �� � � ��$�$�$rC�rtrc�r�||jj|||jj���}|�|��S)a�Emit a COMMENT ON operation to set the comment for a table using the current batch migration context. :param comment: string value of the comment being registered against the specified table. :param existing_comment: String value of a comment already registered on the specified table, used within autogenerate so that the operation is reversible, but not required for direct use. rvr�)rcr�r:rtr�s rArpz/CreateTableCommentOp.batch_create_table_comment�sF��(�S� �O� &� �-��?�)�  � � �� � � ��$�$�$rC�/Union[CreateTableCommentOp, DropTableCommentOp]c��|j�!t|j|j|j���St |j|j|j|j���S)�2Reverses the COMMENT ON operation against a table.Nrv)rt�DropTableCommentOprr:r{rrr?s rArIzCreateTableCommentOp.reverses_�� � � (�%���!%���{���� � (����%�!%���{� ��� rCrjrkr.c�x�tj|��}|�|j|j|j���S)N)r{r:)rr�rrr{r:r�s rArAzCreateTableCommentOp.to_table's?���,�->�?�?� ���� �O�D�K��� � � � rCrKc�:�d|���|jfS)N�add_table_comment)rArtr?s rArMz"CreateTableCommentOp.to_diff_tuple0s��#�T�]�]�_�_�d�6K�L�LrC) rrWr:r�r{r�rtr�r;r�) r�rrrWr:r�rtr�r{r�r;r�)r�rr:r�rtr�r;r�)r;rzrFrQrN) rOrPrQrRr�rvrorprIrArMr>rCrArrrr�s������� 4�3�!%�*.� � � � � � ��+/� $�!%�!%�!%�!%�!%��[�!%�F� +/� %�%�%�%�%��[�%�6����"?C� � � � � �M�M�M�M�M�MrCrr�drop_table_comment�batch_drop_table_commentc�|�eZdZdZddd�dd �Zeddd �dd���Zedd�dd���Zdd�Z dd d�Z d!d�Z dS)"r}z:Represent an operation to remove the comment from a table.NrsrrWr{r�rtr;r�c�0�||_||_||_dSrF)rrtr{)r@rr{rts rAr�zDropTableCommentOp.__init__;s��%��� 0����� � � rCrvr�rc�H�||||���}|�|��S)a�Issue a "drop table comment" operation to remove an existing comment set on a table. :param table_name: string name of the target table. :param existing_comment: An optional string value of a comment already registered on the specified table. .. seealso:: :meth:`.Operations.create_table_comment` :paramref:`.Operations.alter_column.comment` rvr�)rcr�rrtr{r�s rAr�z%DropTableCommentOp.drop_table_commentFs/��0�S��.>�v� N� N� N��� � ��$�$�$rCrxrc�p�||jj||jj���}|�|��S)aIssue a "drop table comment" operation to remove an existing comment set on a table using the current batch operations context. :param existing_comment: An optional string value of a comment already registered on the specified table. rvr�)rcr�rtr�s rAr�z+DropTableCommentOp.batch_drop_table_commentasC�� �S� �O� &�-��?�)� � � �� � � ��$�$�$rCrrc�D�t|j|j|j���S)r|r�)rrrrtr{r?s rArIzDropTableCommentOp.reversexs'��#� �O�T�2�4�;� � � � rCrjrkr.c�l�tj|��}|�|j|j���Sri)rr�rrr{r�s rArAzDropTableCommentOp.to_table~s2���,�->�?�?� ������� ��D�D�DrCrKc�.�d|���fS)N�remove_table_commentrEr?s rArMz DropTableCommentOp.to_diff_tuple�s��&�� � ���8�8rC)rrWr{r�rtr�r;r�) r�rrrWrtr�r{r�r;r�)r�rrtr�r;r�)r;rrrFrQrN) rOrPrQrRr�rvr�r�rIrArMr>rCrAr}r}4s������� E�D� !%�*.� � � � � � �� +/� $� %�%�%�%�%��[�%�4� +/� %�%�%�%�%��[�%�, � � � �?C�E�E�E�E�E�9�9�9�9�9�9rCr}� alter_column�batch_alter_columnc ���eZdZdZddddddddddd� d/�fd�Zd0d�Zd1d�Zd2d�Zeddddddddddd� d3d)���Z edddddddddddd*� d4d.���Z �xZ S)5� AlterColumnOpz$Represent an alter column operation.NF) r{� existing_type�existing_server_default�existing_nullablert�modify_nullable�modify_comment�modify_server_default� modify_name� modify_typerrW� column_namer{r�r�� Optional[Any]r�rr�r�rtr�r��$Optional[Union[str, Literal[False]]]r�r�r�r�r;r�c  ����t���||���||_||_||_||_||_||_| |_| |_ | |_ | |_ | |_ dSri) rjr�r�r�r�r�rtr�r�r�r�r�r�)r@rr�r{r�r�r�rtr�r�r�r�r�r�rks �rAr�zAlterColumnOp.__init__�s}���" ������F��3�3�3�&���*���'>��$�!2��� 0���.���,���%:��"�&���&�������rCc �<�g}|j|j|j}}}|j�9|�d||||j|j|jd�|j|jf��|j �9|�d||||j|j|jd�|j|j f��|j dur9|�d||||j|j|jd�|j|j f��|j dur9|�d||||j|j|jd �|j|j f��|S) Nr�)r�r�rtr�)r�r�rtF�modify_default)r�r�rtr�)r�r�r�) r{rr�r��appendr�r�rtr�r�r�r�)r@�col_diffr{�tname�cnames rArMzAlterColumnOp.to_diff_tuple�s�����#�{�D�O�T�=M�u��� � � '� �O�O�!����-1�-C� �8�,0�,A� ���&��$�� � � �$ � � +� �O�O�%����)-�);� �8�,0�,A� ���*��(�� � � �$ � %�U� 2� 2� �O�O�$����-1�-C�)-�);�,0�,A��� �0��.� � � � � � �e� +� +� �O�O�$����-1�-C�)-�);� �8� ���)��'�� � � �$�rCrc��|jdup|jdup|jdup|jdu}|rdS|jD]}|�d��rdS�dS)NFT�modify_)r�r�r�r�r�� startswith)r@�hc1r�s rA� has_changeszAlterColumnOp.has_changes�s��� � �� ,� 0��)��6� 0���t�+� 0��"�%�/� � � ��4��'� � �B��}�}�Y�'�'� ��t�t� ��5rCc���|j���}|j|d<|j|d<|j|d<|j|d<|j� |j|d<|j� |j|d<|jdur |j|d<|j dur |j |d <d �d �|D��D��}|D]-}d |z|vr$|d |z}|d |z|d |z<||d |z<�.|j |j |j fd|j i|��S)Nr�r�r�rtr�r�Fr�r�c�<�h|]}|�|�d����S)r)�group)r��ms rA� <setcomp>z(AlterColumnOp.reverse.<locals>.<setcomp>s8�� � � ��� � �G�G�A�J�J� � � rCc�8�g|]}tjd|����S)z^(?:existing_|modify_)(.+)$)�rer�)r��ks rAr�z)AlterColumnOp.reverse.<locals>.<listcomp>s%��N�N�N�a�b�h�=�q�A�A�N�N�NrCz modify_%sz existing_%sr{)r�rNr�r�r�rtr�r�r�r�rkrr�r{)r@r��all_keysr��swaps rArIzAlterColumnOp.reverse sf�� �W�\�\�^�^��"�0��?��"&�"8�� ��(,�(D�� $�%�!%�!6�� �� � � '� $� 0�B�}� � � � +�$(�$8�B� � !� � %�U� 2� 2�*.�*D�B�&� '� � �e� +� +�#'�#6�B�� � � �N�N�2�N�N�N� � � �� � +� +�A��Q��"�$�$��-�!�+�,��(*�;��?�(;��=�1�$�%�&*��;��?�#���t�~� �O�T�-� � �6:�k� �EG� � � rC) �nullabler:�server_default�new_column_namerZr�r�r�rtr{r�rr�r:r�r�rZ�7Optional[Union[TypeEngine[Any], Type[TypeEngine[Any]]]]�.Optional[Union[str, bool, Identity, Computed]]c  �V�|||f| | | | | |||||d� |��}|�|��S)agIssue an "alter column" instruction using the current migration context. Generally, only that aspect of the column which is being changed, i.e. name, type, nullability, default, needs to be specified. Multiple changes can also be specified at once and the backend should "do the right thing", emitting each change either separately or together as the backend allows. MySQL has special requirements here, since MySQL cannot ALTER a column without a full specification. When producing MySQL-compatible migration files, it is recommended that the ``existing_type``, ``existing_server_default``, and ``existing_nullable`` parameters be present, if not being altered. Type changes which are against the SQLAlchemy "schema" types :class:`~sqlalchemy.types.Boolean` and :class:`~sqlalchemy.types.Enum` may also add or drop constraints which accompany those types on backends that don't support them natively. The ``existing_type`` argument is used in this case to identify and remove a previous constraint that was bound to the type object. :param table_name: string name of the target table. :param column_name: string name of the target column, as it exists before the operation begins. :param nullable: Optional; specify ``True`` or ``False`` to alter the column's nullability. :param server_default: Optional; specify a string SQL expression, :func:`~sqlalchemy.sql.expression.text`, or :class:`~sqlalchemy.schema.DefaultClause` to indicate an alteration to the column's default value. Set to ``None`` to have the default removed. :param comment: optional string text of a new comment to add to the column. :param new_column_name: Optional; specify a string name here to indicate the new name within a column rename operation. :param type\_: Optional; a :class:`~sqlalchemy.types.TypeEngine` type object to specify a change to the column's type. For SQLAlchemy types that also indicate a constraint (i.e. :class:`~sqlalchemy.types.Boolean`, :class:`~sqlalchemy.types.Enum`), the constraint is also generated. :param autoincrement: set the ``AUTO_INCREMENT`` flag of the column; currently understood by the MySQL dialect. :param existing_type: Optional; a :class:`~sqlalchemy.types.TypeEngine` type object to specify the previous type. This is required for all MySQL column alter operations that don't otherwise specify a new type, as well as for when nullability is being changed on a SQL Server column. It is also used if the type is a so-called SQLAlchemy "schema" type which may define a constraint (i.e. :class:`~sqlalchemy.types.Boolean`, :class:`~sqlalchemy.types.Enum`), so that the constraint can be dropped. :param existing_server_default: Optional; The existing default value of the column. Required on MySQL if an existing default is not being changed; else MySQL removes the default. :param existing_nullable: Optional; the existing nullability of the column. Required on MySQL if the existing nullability is not being changed; else MySQL sets this to NULL. :param existing_autoincrement: Optional; the existing autoincrement of the column. Used for MySQL's system of altering a column that specifies ``AUTO_INCREMENT``. :param existing_comment: string text of the existing comment on the column to be maintained. Required on MySQL if the existing comment on the column is not being changed. :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. :param postgresql_using: String argument which will indicate a SQL expression to render within the Postgresql-specific USING clause within ALTER COLUMN. This string is taken directly as raw SQL which must explicitly include any necessary quoting or escaping of tokens within the expression. ) r{r�r�r�rtr�r�r�r�r�r�)rcr�rr�r�r:r�r�rZr�r�r�rtr{r��alts rAr�zAlterColumnOp.alter_column+sf��T�c� � � ��'�$;�/�-�'��"0�$�"� � �� � �� � � ��%�%�%rC) r�r:r�r�rZr�r�r�rt� insert_before� insert_afterrr�r�c  ��||jj|f|jj|| | | |||||| | d� |��}|�|��S)a2Issue an "alter column" instruction using the current batch migration context. Parameters are the same as that of :meth:`.Operations.alter_column`, as well as the following option(s): :param insert_before: String name of an existing column which this column should be placed before, when creating the new table. :param insert_after: String name of an existing column which this column should be placed after, when creating the new table. If both :paramref:`.BatchOperations.alter_column.insert_before` and :paramref:`.BatchOperations.alter_column.insert_after` are omitted, the column is inserted after the last existing column in the table. .. seealso:: :meth:`.Operations.alter_column` ) r{r�r�r�rtr�r�r�r�r�r�r�r�)rcr�r�r�r:r�r�rZr�r�r�rtr�r�r�r�s rAr�z AlterColumnOp.batch_alter_column�sv��Z�c� �O� &� � ��?�)�'�$;�/�-�'��"0�$�"�'�%� � �� � ��$� � ��%�%�%rC)rrWr�rWr{r�r�r�r�rr�r�rtr�r�r�r�r�r�rr�r�r�r�r�rr;r��r;r�r;r)r;r�)r�rrrWr�rWr�r�r:r�r�rr�r�rZr�r�r�r�r�r�r�rtr�r{r�r�rr;r�)r�rr�rWr�r�r:r�r�rr�r�rZr�r�r�r�r�r�r�rtr�r�r�r�r�r�rr;r�) rOrPrQrRr�rMr�rIrvr�r�rmrns@rAr�r��sW�������/�.�!%�'+�',�,0�*.�*.�?D�%*�%)�%)���������<N�N�N�N�` � � � � � � � �@�$(�8=�#�)-�IM� � �,0�*.� $�'y&�y&�y&�y&�y&��[�y&�v� $(�8=�#�)-�IM� � �,0�*.�'+�&*�'>&�>&�>&�>&�>&��[�>&�>&�>&�>&�>&rCr�� add_column�batch_add_columnc���eZdZdZdd�d �fd�Zd!d�Zd"d�Zd#d�Zed$d���Z ed%d���Z edd�d&d���Z eddd�d'd���Z �xZ S)(� AddColumnOpz"Represent an add column operation.Nr�rrW�column� Column[Any]r{r�r�rr;r�c �j��t���||���||_||_dSri)rjr�r�r�)r@rr�r{r�rks �rAr�zAddColumnOp.__init__�s4��� ������F��3�3�3��� �����rC� DropColumnOpc�X�t�|j|j|j��SrF)r��from_column_and_tablenamer{rr�r?s rArIzAddColumnOp.reverse�s'���5�5� �K���$�+� � � rC�+Tuple[str, Optional[str], str, Column[Any]]c�,�d|j|j|jfS)Nr�)r{rr�r?s rArMzAddColumnOp.to_diff_tuple�s���d�k�4�?�D�K�H�HrCc��|jSrF)r�r?s rA� to_columnzAddColumnOp.to_columns ���{�rC�colc�F�||jj||jj���Sri)rr�r{)rcr�s rA� from_columnzAddColumnOp.from_columns"���s�3�9�>�3�s�y�/?�@�@�@�@rCr�c��||||���Srir>�rcr{r�r�s rAr�z%AddColumnOp.from_column_and_tablename s���s�5�#�f�-�-�-�-rCr�rc�H�||||���}|�|��S)a� Issue an "add column" instruction using the current migration context. e.g.:: from alembic import op from sqlalchemy import Column, String op.add_column("organization", Column("name", String())) The :meth:`.Operations.add_column` method typically corresponds to the SQL command "ALTER TABLE... ADD COLUMN". Within the scope of this command, the column's name, datatype, nullability, and optional server-generated defaults may be indicated. .. note:: With the exception of NOT NULL constraints or single-column FOREIGN KEY constraints, other kinds of constraints such as PRIMARY KEY, UNIQUE or CHECK constraints **cannot** be generated using this method; for these constraints, refer to operations such as :meth:`.Operations.create_primary_key` and :meth:`.Operations.create_check_constraint`. In particular, the following :class:`~sqlalchemy.schema.Column` parameters are **ignored**: * :paramref:`~sqlalchemy.schema.Column.primary_key` - SQL databases typically do not support an ALTER operation that can add individual columns one at a time to an existing primary key constraint, therefore it's less ambiguous to use the :meth:`.Operations.create_primary_key` method, which assumes no existing primary key constraint is present. * :paramref:`~sqlalchemy.schema.Column.unique` - use the :meth:`.Operations.create_unique_constraint` method * :paramref:`~sqlalchemy.schema.Column.index` - use the :meth:`.Operations.create_index` method The provided :class:`~sqlalchemy.schema.Column` object may include a :class:`~sqlalchemy.schema.ForeignKey` constraint directive, referencing a remote table name. For this specific type of constraint, Alembic will automatically emit a second ALTER statement in order to add the single-column FOREIGN KEY constraint separately:: from alembic import op from sqlalchemy import Column, INTEGER, ForeignKey op.add_column( "organization", Column("account_id", INTEGER, ForeignKey("accounts.id")), ) The column argument passed to :meth:`.Operations.add_column` is a :class:`~sqlalchemy.schema.Column` construct, used in the same way it's used in SQLAlchemy. In particular, values or functions to be indicated as producing the column's default value on the database side are specified using the ``server_default`` parameter, and not ``default`` which only specifies Python-side defaults:: from alembic import op from sqlalchemy import Column, TIMESTAMP, func # specify "DEFAULT NOW" along with the column add op.add_column( "account", Column("timestamp", TIMESTAMP, server_default=func.now()), ) :param table_name: String name of the parent table. :param column: a :class:`sqlalchemy.schema.Column` object representing the new column. :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. r�r�)rcr�rr�r{r�s rAr�zAddColumnOp.add_columns/��n�S��V�F� 3� 3� 3��� � ��$�$�$rC)r�r�rr�r�c��i}|r||d<|r||d<||jj|fd|jji|��}|�|��S)z�Issue an "add column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.add_column` r�r�r{r�)rcr�r�r�r�r�r�s rAr�zAddColumnOp.batch_add_columnns}��$�� � 0�"/�B�� � � .�!-�B�~� � �S� �O� &� � � ��?�)� ��  � �� � � ��$�$�$rC) rrWr�r�r{r�r�rr;r�)r;r��r;r�)r;r�)r�r�r;r�)r{r�r�rWr�r�r;r�) r�rrrWr�r�r{r�r;r�) r�rr�r�r�r�r�r�r;r�)rOrPrQrRr�rIrMr�rvr�r�r�r�rmrns@rAr�r��s@�������-�,�!%� � � � � � � � � � � � � I�I�I�I� �����A�A�A��[�A��.�.�.��[�.��!%� W%�W%�W%�W%�W%��[�W%�r� (,�&*� %�%�%�%�%��[�%�%�%�%�%rCr�� drop_column�batch_drop_columnc���eZdZdZddd�d!�fd�Zd"d�Zd#d�Zed$d���Z d%d&d�Z edd�d'd���Z ed(d ���Z �xZ S))r�z"Represent a drop column operation.NrzrrWr�r{r�r|�Optional[AddColumnOp]r�rr;r�c �x��t���||���||_||_||_dSri)rjr�r�r�r|)r@rr�r{r|r�rks �rAr�zDropColumnOp.__init__�s<��� ������F��3�3�3�&������ �� � � rCr�c�F�d|j|j|���fS)N� remove_column)r{rr�r?s rArMzDropColumnOp.to_diff_tuple�s(�� � �K� �O� �N�N� � �  � rCr�c��|j�td���t�|j|j|jj��S)Nz;operation is not reversible; original column is not present)r|r�r�r�r{rr�r?s rArIzDropColumnOp.reverse�sK�� �=� ��1��� � �4�4� �K���$�-�*>� � � rCr�r�r�c �^�|||j|t�|||�����S)Nrz)r�r�r�r�s rAr�z&DropColumnOp.from_column_and_tablename�s=���s� � �H�� �:�:�6�5�#�N�N�  � � � rCrjrkc��|j� |jjStj|��}|�|jt ��SrF)r|r�rr�r�rr�s rAr�zDropColumnOp.to_column�sA�� �=� $��=�'� '��,�->�?�?� �� � ��!1�8�<�<�<rCr�r�rc �D�|||fd|i|��}|�|��S)ayIssue a "drop column" instruction using the current migration context. e.g.:: drop_column("organization", "account_id") :param table_name: name of table :param column_name: name of column :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use the SQLAlchemy construct :class:`~sqlalchemy.sql.elements.quoted_name`. :param mssql_drop_check: Optional boolean. When ``True``, on Microsoft SQL Server only, first drop the CHECK constraint on the column using a SQL-script-compatible block that selects into a @variable from sys.check_constraints, then exec's a separate DROP CONSTRAINT for that constraint. :param mssql_drop_default: Optional boolean. When ``True``, on Microsoft SQL Server only, first drop the DEFAULT constraint on the column using a SQL-script-compatible block that selects into a @variable from sys.default_constraints, then exec's a separate DROP CONSTRAINT for that default. :param mssql_drop_foreign_key: Optional boolean. When ``True``, on Microsoft SQL Server only, first drop a single FOREIGN KEY constraint on the column using a SQL-script-compatible block that selects into a @variable from sys.foreign_keys/sys.foreign_key_columns, then exec's a separate DROP CONSTRAINT for that default. Only works if the column has exactly one FK constraint which refers to it, at the moment. r{r�)rcr�rr�r{r�r�s rAr�zDropColumnOp.drop_column�s7��^�S��[� >� >�� >�2� >� >��� � ��$�$�$rCrc �l�||jj|fd|jji|��}|�|��S)z�Issue a "drop column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_column` r{r�)rcr�r�r�r�s rAr�zDropColumnOp.batch_drop_column�sT���S� �O� &� � � ��?�)� ��  � �� � � ��$�$�$rC) rrWr�rWr{r�r|r�r�rr;r�r�)r;r�)r{r�r�rWr�r�r;r�rF)rjrkr;r�) r�rrrWr�rWr{r�r�rr;r�)r�rr�rWr�rr;r�) rOrPrQrRr�rMrIrvr�r�r�r�rmrns@rAr�r��s�������-�,�!%�*.� !� !� !� !� !� !� !� !� � � � �  �  �  �  ��  �  �  ��[�  �?C�=�=�=�=�=��!%� /%�/%�/%�/%�/%��[�/%�b�%�%�%��[�%�%�%�%�%rCr�� bulk_insertc�>�eZdZdZdd�dd �Zedd�dd���ZdS)� BulkInsertOpz"Represent a bulk insert operation.T�� multiinsertr�Union[Table, TableClause]�rows�List[Dict[str, Any]]r�rr;r�c�0�||_||_||_dSrF)rr�r�)r@rr�r�s rAr�zBulkInsertOp.__init__ s ���� ��� �&����rCr�rc�L�||||���}|�|��dS)axIssue a "bulk insert" operation using the current migration context. This provides a means of representing an INSERT of multiple rows which works equally well in the context of executing on a live connection as well as that of generating a SQL script. In the case of a SQL script, the values are rendered inline into the statement. e.g.:: from alembic import op from datetime import date from sqlalchemy.sql import table, column from sqlalchemy import String, Integer, Date # Create an ad-hoc table to use for the insert statement. accounts_table = table( "account", column("id", Integer), column("name", String), column("create_date", Date), ) op.bulk_insert( accounts_table, [ { "id": 1, "name": "John Smith", "create_date": date(2010, 10, 5), }, { "id": 2, "name": "Ed Williams", "create_date": date(2007, 5, 27), }, { "id": 3, "name": "Wendy Jones", "create_date": date(2008, 8, 15), }, ], ) When using --sql mode, some datatypes may not render inline automatically, such as dates and other special types. When this issue is present, :meth:`.Operations.inline_literal` may be used:: op.bulk_insert( accounts_table, [ { "id": 1, "name": "John Smith", "create_date": op.inline_literal("2010-10-05"), }, { "id": 2, "name": "Ed Williams", "create_date": op.inline_literal("2007-05-27"), }, { "id": 3, "name": "Wendy Jones", "create_date": op.inline_literal("2008-08-15"), }, ], multiinsert=False, ) When using :meth:`.Operations.inline_literal` in conjunction with :meth:`.Operations.bulk_insert`, in order for the statement to work in "online" (e.g. non --sql) mode, the :paramref:`~.Operations.bulk_insert.multiinsert` flag should be set to ``False``, which will have the effect of individual INSERT statements being emitted to the database, each with a distinct VALUES clause, so that the "inline" values can still be rendered, rather than attempting to pass the values as bound parameters. :param table: a table object which represents the target of the INSERT. :param rows: a list of dictionaries indicating rows. :param multiinsert: when at its default of True and --sql mode is not enabled, the INSERT statement will be executed using "executemany()" style, where all elements in the list of dictionaries are passed as bound parameters in a single list. Setting this to False results in individual INSERT statements being emitted per parameter set, and is needed in those cases where non-literal values are present in the parameter sets. r�Nr�)rcr�rr�r�r�s rAr�zBulkInsertOp.bulk_insert# s5��R�S���+� 6� 6� 6�����"�����rCN)rr�r�r�r�rr;r�) r�rrr�r�r�r�rr;r�)rOrPrQrRr�rvr�r>rCrAr�r� st������,�,�!� '� '� '� '� '� '��!� i�i�i�i�i��[�i�i�irCr��execute� batch_executec�d�eZdZdZdd�dd �Zedd�dd ���Zedd�dd���Zdd�ZdS)� ExecuteSQLOpz#Represent an execute SQL operation.N��execution_optionsr��Union[Executable, str]r��Optional[dict[str, Any]]r;r�c�"�||_||_dSrF)r�r�)r@r�r�s rAr�zExecuteSQLOp.__init__� s�� �� �!2����rCr�rc�F�|||���}|�|��S)a� Execute the given SQL using the current migration context. The given SQL can be a plain string, e.g.:: op.execute("INSERT INTO table (foo) VALUES ('some value')") Or it can be any kind of Core SQL Expression construct, such as below where we use an update construct:: from sqlalchemy.sql import table, column from sqlalchemy import String from alembic import op account = table("account", column("name", String)) op.execute( account.update() .where(account.c.name == op.inline_literal("account 1")) .values({"name": op.inline_literal("account 2")}) ) Above, we made use of the SQLAlchemy :func:`sqlalchemy.sql.expression.table` and :func:`sqlalchemy.sql.expression.column` constructs to make a brief, ad-hoc table construct just for our UPDATE statement. A full :class:`~sqlalchemy.schema.Table` construct of course works perfectly fine as well, though note it's a recommended practice to at least ensure the definition of a table is self-contained within the migration script, rather than imported from a module that may break compatibility with older migrations. In a SQL script context, the statement is emitted directly to the output stream. There is *no* return result, however, as this function is oriented towards generating a change script that can run in "offline" mode. Additionally, parameterized statements are discouraged here, as they *will not work* in offline mode. Above, we use :meth:`.inline_literal` where parameters are to be used. For full interaction with a connected database where parameters can also be used normally, use the "bind" available from the context:: from alembic import op connection = op.get_bind() connection.execute( account.update() .where(account.c.name == "account 1") .values({"name": "account 2"}) ) Additionally, when passing the statement as a plain string, it is first coerced into a :func:`sqlalchemy.sql.expression.text` construct before being passed along. In the less likely case that the literal SQL string contains a colon, it must be escaped with a backslash, as:: op.execute(r"INSERT INTO table (foo) VALUES ('\:colon_value')") :param sqltext: Any legal SQLAlchemy expression, including: * a string * a :func:`sqlalchemy.sql.expression.text` construct. * a :func:`sqlalchemy.sql.expression.insert` construct. * a :func:`sqlalchemy.sql.expression.update` construct. * a :func:`sqlalchemy.sql.expression.delete` construct. * Any "executable" described in SQLAlchemy Core documentation, noting that no result set is returned. .. note:: when passing a plain string, the statement is coerced into a :func:`sqlalchemy.sql.expression.text` construct. This construct considers symbols with colons, e.g. ``:foo`` to be bound parameters. To avoid this, ensure that colon symbols are escaped, e.g. ``\:foo``. :param execution_options: Optional dictionary of execution options, will be passed to :meth:`sqlalchemy.engine.Connection.execution_options`. r�r�)rcr�r�r�r�s rAr�zExecuteSQLOp.execute� s.��p�S��,=� >� >� >��� � ��$�$�$rCc�2�|�|||���S)z�Execute the given SQL using the current migration context. .. seealso:: :meth:`.Operations.execute` r�)r�)rcr�r�r�s rAr�zExecuteSQLOp.batch_execute� s'���{�{� ��3D�� � � rC�"Tuple[str, Union[Executable, str]]c��d|jfS)Nr�)r�r?s rArMzExecuteSQLOp.to_diff_tuple s���4�<�(�(rC)r�r�r�r�r;r�)r�rr�r�r�r�r;r�)r;r�) rOrPrQrRr�rvr�r�rMr>rCrAr�r�� s�������.�-� 7;� 3�3�3�3�3�3�� 7;� X%�X%�X%�X%�X%��[�X%�t� 7;�  � � � � ��[� �$)�)�)�)�)�)rCr�c�D�eZdZdZddd�Zdd �Zdd �Zedd���ZdS)� OpContainerz-Represent a sequence of operations operation.r>�ops�Sequence[MigrateOperation]r;r�c�.�t|��|_dSrF)rHr�)r@r�s rAr�zOpContainer.__init__ s����9�9����rCrc��|j SrF�r�r?s rA�is_emptyzOpContainer.is_empty s ���8�|�rCrc�P�tt�|����SrF)rHr�� _ops_as_diffsr?s rA�as_diffszOpContainer.as_diffs s���K�-�-�d�3�3�4�4�4rC� migrations�Iterator[Tuple[Any, ...]]c#�K�|jD]R}t|d��r*|�td|����Ed{V���<|���V��SdS)Nr�r�)r��hasattrr�rrM)rcrr�s rAr�zOpContainer._ops_as_diffs s������.� )� )�B��r�5�!�!� )��,�,�T�-��-D�-D�E�E�E�E�E�E�E�E�E�E��&�&�(�(�(�(�(�(�  )� )rCN)r>)r�r�r;r�r�r�)rr�r;r) rOrPrQrRr�r�r�rvr�r>rCrAr�r� s{������7�7����������5�5�5�5��)�)�)��[�)�)�)rCr�c�2��eZdZdZdd�d�fd �Zdd �Z�xZS)�ModifyTableOpszCContains a sequence of operations that all apply to a single Table.Nr�rrWr�r�r{r�r;r�c�f��t���|��||_||_dSrF)rjr�rr{)r@rr�r{rks �rAr�zModifyTableOps.__init__* s/��� ���������$����� � � rCc ��t|jttd�|jD������|j���S)Nc�6�g|]}|�����Sr>�rI�r�r�s rAr�z*ModifyTableOps.reverse.<locals>.<listcomp>8 � ��?�?�?��r�z�z�|�|�?�?�?rC)r�r{)rrrH�reversedr�r{r?s rArIzModifyTableOps.reverse5 sG��� �O��X�?�?�d�h�?�?�?�@�@�A�A��;� � � � rC)rrWr�r�r{r�r;r�)r;r�rOrPrQrRr�rIrmrns@rArr' sf�������M�M�!%� � � � � � � � � � � � � � � � rCrc�:��eZdZdZ dd�fd � Zdd �Zdd�Z�xZS)� UpgradeOpsz�contains a sequence of operations that would apply to the 'upgrade' stream of a script. .. seealso:: :ref:`customizing_revision` r>�upgradesr�r�� upgrade_tokenrWr;r�c�Z��t���|���||_dS�Nr�)rjr�r)r@r�rrks �rAr�zUpgradeOps.__init__G s.��� �����S��!�!�!�*����rC� downgrade_ops� DowngradeOpsc�p�ttd�|jD������|jdd�<|S)Nc�6�g|]}|�����Sr>r r s rAr�z+UpgradeOps.reverse_into.<locals>.<listcomp>Q s ��6�6�6�r�b�j�j�l�l�6�6�6rC)rHr r�)r@rs rA� reverse_intozUpgradeOps.reverse_intoO sA��#� �6�6�T�X�6�6�6� 7� 7� � � ��!�!�!���rCc�H�|�tg�����Sr)rrr?s rArIzUpgradeOps.reverseU s!��� � ��"�!5�!5�!5�6�6�6rC)r>r)r�r�rrWr;r�)rrr;r)r;r)rOrPrQrRr�rrIrmrns@rArr= s|���������+-�'�+�+�+�+�+�+�+����� 7�7�7�7�7�7�7�7rCrc�2��eZdZdZ d d�fd � Zdd �Z�xZS)rz�contains a sequence of operations that would apply to the 'downgrade' stream of a script. .. seealso:: :ref:`customizing_revision` r>� downgradesr�r��downgrade_tokenrWr;r�c�Z��t���|���||_dSr)rjr�r)r@r�rrks �rAr�zDowngradeOps.__init__c s.��� �����S��!�!�!�.����rCrc�t�tttd�|jD���������S)Nc�6�g|]}|�����Sr>r r s rAr�z(DowngradeOps.reverse.<locals>.<listcomp>m r rCr�)rrHr r�r?s rArIzDowngradeOps.reversek s=����X�?�?�d�h�?�?�?�@�@�A�A� � � � rC)r>r)r�r�rrWr;r�)r;rr rns@rArrY sh���������+-�+�/�/�/�/�/�/�/� � � � � � � � rCrc��eZdZUdZded<ded<ded<de��dddddd �d&d�Zed'd���Zej d(d���Zed)d!���Z e j d*d#���Z ed+d$���Z ed,d%���Z dS)-�MigrationScriptaprepresents a migration script. E.g. when autogenerate encounters this object, this corresponds to the production of an actual script file. A normal :class:`.MigrationScript` object would contain a single :class:`.UpgradeOps` and a single :class:`.DowngradeOps` directive. These are accessible via the ``.upgrade_ops`` and ``.downgrade_ops`` attributes. In the case of an autogenerate operation that runs multiple times, such as the multiple database example in the "multidb" template, the ``.upgrade_ops`` and ``.downgrade_ops`` attributes are disabled, and instead these objects should be accessed via the ``.upgrade_ops_list`` and ``.downgrade_ops_list`` list-based attributes. These latter attributes are always available at the very least as single-element lists. .. seealso:: :ref:`customizing_revision` r�� _needs_render�List[UpgradeOps]� _upgrade_ops�List[DowngradeOps]�_downgrade_opsN)�message�imports�head�splice� branch_label� version_path� depends_on�rev_idr�� upgrade_opsrrrr'r(�Set[str]r)r*r+�Optional[_RevIdType]r,r-r;r�c��||_||_||_||_||_||_| |_| |_||_||_ dSrF) r.r'r(r)r*r+r,r-r/r) r@r.r/rr'r(r)r*r+r,r-s rAr�zMigrationScript.__init__� sT���� ��� ��� ��� ��� �(���(���$���&���*����rC�Optional[UpgradeOps]c�|�t|j��dkrtd���|jsdS|jdS)zzAn instance of :class:`.UpgradeOps`. .. seealso:: :attr:`.MigrationScript.upgrade_ops_list` rzrThis MigrationScript instance has a multiple-entry list for UpgradeOps; please use the upgrade_ops_list attribute.Nr)�lenr$r�r?s rAr/zMigrationScript.upgrade_ops� sQ�� �t� � !� !�A� %� %��.��� � �"� (��4��$�Q�'� 'rC�#Union[UpgradeOps, List[UpgradeOps]]c�z�tj|��|_|jD]}t|t��sJ��dSrF)r�to_listr$� isinstancer)r@r/�elems rAr/zMigrationScript.upgrade_ops� sK��!�L��5�5����%� 0� 0�D��d�J�/�/� /� /�/� /� 0� 0rC�Optional[DowngradeOps]c�|�t|j��dkrtd���|jsdS|jdS)z~An instance of :class:`.DowngradeOps`. .. seealso:: :attr:`.MigrationScript.downgrade_ops_list` rzvThis MigrationScript instance has a multiple-entry list for DowngradeOps; please use the downgrade_ops_list attribute.Nr)r5r&r�r?s rArzMigrationScript.downgrade_ops� sQ�� �t�"� #� #�a� '� '��0��� � �$� *��4��&�q�)� )rC�'Union[DowngradeOps, List[DowngradeOps]]c�z�tj|��|_|jD]}t|t��sJ��dSrF)rr8r&r9r)r@rr:s rArzMigrationScript.downgrade_ops� sK��#�l�=�9�9����'� 2� 2�D��d�L�1�1� 1� 1�1� 1� 2� 2rCc��|jS)z�A list of :class:`.UpgradeOps` instances. This is used in place of the :attr:`.MigrationScript.upgrade_ops` attribute when dealing with a revision operation that does multiple autogenerate passes. )r$r?s rA�upgrade_ops_listz MigrationScript.upgrade_ops_list� s ��� � rCc��|jS)z�A list of :class:`.DowngradeOps` instances. This is used in place of the :attr:`.MigrationScript.downgrade_ops` attribute when dealing with a revision operation that does multiple autogenerate passes. )r&r?s rA�downgrade_ops_listz"MigrationScript.downgrade_ops_list� s ���"�"rC)r.r�r/rrrr'r�r(r0r)r�r*r�r+r1r,r�r-r1r;r�)r;r3)r/r6r;r�)r;r;)rr=r;r�)r;r#)r;r%) rOrPrQrRrU�setr�rur/�setterrr@rBr>rCrAr!r!q sI���������."�!�!�!�"�"�"�"�&�&�&�&�"&��C�E�E�"�!%�-1�&*�+/�+�+�+�+�+�+�2�(�(�(��X�(�$��0�0�0���0��*�*�*��X�*�$��2�2�2���2��!�!�!��X�!��#�#�#��X�#�#�#rCr!)]� __future__r�abcrr��typingrrrrr r r r r rrrrrrr�sqlalchemy.typesr�r�baserrrrr�sqlalchemy.sqlr�sqlalchemy.sql.elementsrr r!r"�sqlalchemy.sql.functionsr#�sqlalchemy.sql.schemar$r%r&r'r(r)r*r+r,r-r.r/�sqlalchemy.sql.selectabler0�sqlalchemy.sql.type_apir1�autogenerate.rewriterr2�runtime.migrationr3�script.revisionr4r5r7r:r8�register_operationrnrer�r�r�r�rrr4r=rarerrr}r�r�r�r�r�r�rrrr!r>rCrA�<module>rUsj ��"�"�"�"�"�"������� � � � �������������������������������������������!�!�!�!�!�!������������������������������� � � � � � �������������%�%�%�%�%�%�������!�!�!�!�!�!��������������������-�������)�)�)�)�)�)�5�5�5�5�5�5�,�,�,�,�,�,�3�3�3�3�3�3�2�2�2�2�2�2�1�1�1�1�1�1�5�5�5�5�5�5�,�,�,�,�,�,�.�.�.�.�.�.�0�0�0�0�0�0�:�:�:�:�:�:�.�.�.�.�.�.�+�+�+�+�+�+�.�.�.�.�.�.�:�:�:�:�:�:�0�0�0�0�0�0�+�+�+�+�+�+�6�6�6�6�6�6�5�5�5�5�5�5�2�2�2�2�2�2�0�0�0�0�0�0�4�4�4�4�4�4�,�,�,�,�,�,� �W�T������ �g�e�,�-�-�-��"�"�"�"�"�"�"�"�@#8�#8�#8�#8�#8�&�#8�#8�#8�L���0�1�1�#��#�$5�7N�O�O�r%�r%�r%�r%�r%�'�r%�r%�P�O�2�1�r%�j���3�4�4�#��#��4����(�(�)A�B�B�t%�t%�t%�t%�t%��t%�t%�C�B���5�4� t%�n���9�:�:�#��#�� @����(�(�)<�=�=�%�%�%�%�%��%�%�>�=���;�:� %�D���3�4�4�#��#��4����(�(�)A�B�B�Z%�Z%�Z%�Z%�Z%��Z%�Z%�C�B���5�4� Z%�z���8�9�9�#��#��>����(�(�);�<�<��(�(�)K�L�L��(�(�)B�C�C�%�%�%�%�%�o�%�%�D�C�M�L�=�<���:�9�%�D���~�.�.�#��#�N�4H�I�I�V%�V%�V%�V%�V%�$�V%�V%�J�I�/�.�V%�r���|�,�,�#��#�L�2D�E�E�w%�w%�w%�w%�w%�"�w%�w%�F�E�-�,�w%�t���~�.�.�e%�e%�e%�e%�e%�$�e%�e%�/�.�e%�P���|�,�,�d�d�d�d�d�"�d�d�-�,�d�N � � � � �#� � � ����~�.�.�!%�!%�!%�!%�!%�L�!%�!%�/�.�!%�H���5�6�6�#��#��8���jM�jM�jM�jM�jM�<�jM�jM���7�6�jM�Z���3�4�4�#��#��4���N9�N9�N9�N9�N9��N9�N9���5�4�N9�b���~�.�.�#��#�N�4H�I�I�[&�[&�[&�[&�[&�L�[&�[&�J�I�/�.�[&�| ���|�,�,�#��#�L�2D�E�E�a%�a%�a%�a%�a%�,�a%�a%�F�E�-�,�a%�H���}�-�-�#��#�M�3F�G�G�@%�@%�@%�@%�@%�<�@%�@%�H�G�.�-�@%�F���}�-�-�x�x�x�x�x�#�x�x�.�-�x�v���y�)�)�#��#�I��?�?�{)�{)�{)�{)�{)�#�{)�{)�@�?�*�)�{)�|)�)�)�)�)�"�)�)�)�. � � � � �[� � � �,7�7�7�7�7��7�7�7�8 � � � � �;� � � �0#�#�#�#�#�&�#�#�#�#�#rC
Memory