Hacked By AnonymousFox

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

�

�܋fB����ddlmZddlmZddlmZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZ ddl!m"Z"ddl#m$Z$ddl#m%Z%ddl%m&Z&dd l'm(Z(erNdd!lm)Z)dd"lm*Z*dd#l+m,Z,dd$l+m-Z-dd%l.m/Z/dd&l0m1Z1d'd(l2m3Z3dd)l4m5Z5dd*l6m7Z7dd+l6m8Z8dd,l9m:Z:dd-l9m;Z;dd.l9m<Z<ej=e>��Z?Gd/�d0��Z@Gd1�d2��ZAGd3�d4��ZBGd5�d6��ZCGd7�d8��ZDGd9�d:eD��ZEGd;�d<eD��ZFdS)=�)�annotations)�contextmanager)�nullcontextN)�Any)�Callable)�cast)�
Collection)�ContextManager)�Dict)�Iterable)�Iterator)�List)�Optional)�Set)�Tuple)�
TYPE_CHECKING)�Union)�Column)�literal_column)�MetaData)�PrimaryKeyConstraint)�String)�Table)�Engine)�url)�MockEngineStrategy�)�ddl)�util)�sqla_compat)�	EncodedIO)�Dialect)�URL)�
Connection)�Transaction)�MockConnection)�
ClauseElement�)�EnvironmentContext)�Config)�Script)�ScriptDirectory)�_RevisionOrBase)�Revision)�RevisionMapc�N�eZdZdd�Zedd���Zdd�Zdd	�Zdd
�Zdd�Z	dS)�_ProxyTransaction�migration_context�MigrationContext�return�Nonec��||_dS�N)r2)�selfr2s  �P/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/runtime/migration.py�__init__z_ProxyTransaction.__init__9s��!2������Optional[Transaction]c��|jjSr7)r2�_transaction�r8s r9�_proxied_transactionz&_ProxyTransaction._proxied_transaction<s���%�2�2r;c�\�|j}|�J�|���d|j_dSr7)r@�rollbackr2r>�r8�ts  r9rBz_ProxyTransaction.rollback@s1���%���}�}�}�	�
�
����.2���+�+�+r;c�\�|j}|�J�|���d|j_dSr7)r@�commitr2r>rCs  r9rFz_ProxyTransaction.commitFs1���%���}�}�}�	���
�
�
�.2���+�+�+r;c��|Sr7�r?s r9�	__enter__z_ProxyTransaction.__enter__Ls���r;�type_r�value�	tracebackc�h�|j�*|j�|||��d|j_dSdSr7)r@�__exit__r2r>)r8rJrKrLs    r9rNz_ProxyTransaction.__exit__Os?���$�0��%�.�.�u�e�Y�G�G�G�26�D�"�/�/�/�1�0r;N)r2r3r4r5)r4r<)r4r5)r4r1)rJrrKrrLrr4r5)
�__name__�
__module__�__qualname__r:�propertyr@rBrFrIrNrHr;r9r1r18s�������3�3�3�3��3�3�3��X�3�3�3�3�3�3�3�3�3�����7�7�7�7�7�7r;r1c��eZdZdZ	d?d@d
�Ze							dAdBd���ZedCd���Z	dDdEd�Z	dFd�Z
dGd �ZdDdHd"�ZdId#�Z
dJd(�ZdKd+�ZdId,�Z	d?dLd1�ZdMd3�ZedNd4���ZedOd6���ZdPd;�ZdQd>�ZdS)Rr3a�Represent the database state made available to a migration
    script.

    :class:`.MigrationContext` is the front end to an actual
    database connection, or alternatively a string output
    stream given a particular database dialect,
    from an Alembic perspective.

    When inside the ``env.py`` script, the :class:`.MigrationContext`
    is available via the
    :meth:`.EnvironmentContext.get_context` method,
    which is available at ``alembic.context``::

        # from within env.py script
        from alembic import context

        migration_context = context.get_context()

    For usage outside of an ``env.py`` script, such as for
    utility routines that want to check the current version
    in the database, the :meth:`.MigrationContext.configure`
    method to create new :class:`.MigrationContext` objects.
    For example, to get at the current revision in the
    database using :meth:`.MigrationContext.get_current_revision`::

        # in any application, outside of an env.py script
        from alembic.migration import MigrationContext
        from sqlalchemy import create_engine

        engine = create_engine("postgresql://mydatabase")
        conn = engine.connect()

        context = MigrationContext.configure(conn)
        current_rev = context.get_current_revision()

    The above context can also be used to produce
    Alembic migration operations with an :class:`.Operations`
    instance::

        # in any application, outside of the normal Alembic environment
        from alembic.operations import Operations

        op = Operations(context)
        op.alter_column("mytable", "somecolumn", nullable=True)

    N�dialectr"�
connection�Optional[Connection]�opts�Dict[str, Any]�environment_context�Optional[EnvironmentContext]r4r5c
���||_||_||_|�d��|_|�dd��}|�d��}|�dd��|_|�dd��|_d|_|rDttd|�
|����|_|j�J�d|_n ||_tj|��|_|�d	��|_||_|�d
d��|_d|vr;t%|�d��pt&j|d��|_n%|�dt&j��|_|�d
d��|_|�dd��|_|�dd��x|_}|�dd��x|_}t5|t7��t9dt;d��d���|���|_|�dd��r,|j�tAdd|z�����|�d��|_!tEj#�$|��||j|j||j|��|_%tL�'d|j%j(j)��|jrtL�'d��tL�'d|j%j*rdnd��dS) N�script�as_sqlF�transactional_ddl�transaction_per_migration�on_version_applyrHr$�fn�purge�output_encoding�
output_buffer�compare_type�compare_server_default�
version_table�alembic_version�version_table_schema�version_num� )�nullable)�schema�version_table_pkTz%s_pkc)�name�starting_revzContext impl %s.zGenerating static SQLzWill assume %s DDL.�
transactionalznon-transactional)+rYrWrT�getr\�_transaction_per_migration�on_version_apply_callbacksr>rr�_stdout_connectionrU�_in_external_transactionr �_get_connection_in_transaction�_migrations_fnr]rbr!�sys�stdoutrd�_user_compare_type�_user_compare_server_defaultrgrirrrr�_version�append_constraintr�_start_from_revr�DefaultImpl�get_by_dialect�impl�log�info�	__class__rOr^)	r8rTrUrWrYr]r^rgris	         r9r:zMigrationContext.__init__�sT��$7�� ���	����15���(�1C�1C����x�x��%�0�0�� �H�H�%8�9�9��*.�(�(�'��+
�+
��'�+/�(�(�3E�r�*J�*J��'�37����
	�"���&��(?�(?�
�(K�(K���D�O��?�.�.�.�,1�D�)�)�(�D�O��:�:�F�F�
�)�
�H�H�T�N�N�	
������X�X�g�u�-�-��
���$�$�!*�����)�)���:��&�'�"�"�D���"&���/�3�:�!F�!F�D��"&�(�(�>�5�"A�"A���,0�H�H�$�e�-
�-
��)�.2�X�X��.�.
�.
�	
���]�<@�8�8�"�D�<
�<
�	
��!�$8����J�J��=�&��*�*�u�=�=�=�'�	
�
�
��
��8�8�&��-�-�	��M�+�+�$�!��=�(@����
�
�
�/3�h�h�~�.F�.F����O�2�2�7�;�;���O��K�����

�
��	�	���#�T�Y�%8�%A�B�B�B��;�	.��H�H�,�-�-�-����!��y�*�
%�O�O�$�		
�	
�	
�	
�	
r;r�Optional[Union[str, URL]]�dialect_name�
Optional[str]�Optional[Dialect]�dialect_opts�Optional[Dict[str, str]]�
Optional[Any]c��|�i}|�i}|r4t|t��rtjd|z���|j}nv|r/tj|��}|���di|��}nE|r2tjd|z��}|���di|��}n|std���|�J�t||||��S)a�Create a new :class:`.MigrationContext`.

        This is a factory method usually called
        by :meth:`.EnvironmentContext.configure`.

        :param connection: a :class:`~sqlalchemy.engine.Connection`
         to use for SQL execution in "online" mode.  When present,
         is also used to determine the type of dialect in use.
        :param url: a string database url, or a
         :class:`sqlalchemy.engine.url.URL` object.
         The type of dialect to be used will be derived from this if
         ``connection`` is not passed.
        :param dialect_name: string name of a dialect, such as
         "postgresql", "mssql", etc.  The type of dialect to be used will be
         derived from this if ``connection`` and ``url`` are not passed.
        :param opts: dictionary of options.  Most other options
         accepted by :meth:`.EnvironmentContext.configure` are passed via
         this dictionary.

        Nzf'connection' argument to configure() is expected to be a sqlalchemy.engine.Connection instance, got %rz%s://z-Connection, url, or dialect_name is required.rH)
�
isinstancerr�CommandErrorrT�sqla_url�make_url�get_dialect�	Exceptionr3)	�clsrUrr�rTrYr�rW�url_objs	         r9�	configurezMigrationContext.configure�s��>�<��D����L��	M��*�f�-�-�
��'��)�*����!�(�G�G�
�	M��'��,�,�G�+�g�)�)�+�+�;�;�l�;�;�G�G�
�	M��'��,�(>�?�?�G�+�g�)�)�+�+�;�;�l�;�;�G�G��	M��K�L�L�L��"�"�"����T�;N�O�O�Or;�Iterator[None]c#�K�|���}|jjr!|jr|j���n+|r)|j�J�|j���d|_|jsj|j�J�|j���}|j}|�	d���x|_|j_|j�
��}nd}	dV�|jsM|j�J�|�|���|j�	|���|x|_|j_|jjr"|jr|j���dS|r)|j�J�|j�
��|_dSdS#|jsM|j�J�|�|���|j�	|���|x|_|j_|jjr!|jr|j���n)|r'|j�J�|j�
��|_wxYw)amEnter an "autocommit" block, for databases that support AUTOCOMMIT
        isolation levels.

        This special directive is intended to support the occasional database
        DDL or system operation that specifically has to be run outside of
        any kind of transaction block.   The PostgreSQL database platform
        is the most common target for this style of operation, as many
        of its DDL operations must be run outside of transaction blocks, even
        though the database overall supports transactional DDL.

        The method is used as a context manager within a migration script, by
        calling on :meth:`.Operations.get_context` to retrieve the
        :class:`.MigrationContext`, then invoking
        :meth:`.MigrationContext.autocommit_block` using the ``with:``
        statement::

            def upgrade():
                with op.get_context().autocommit_block():
                    op.execute("ALTER TYPE mood ADD VALUE 'soso'")

        Above, a PostgreSQL "ALTER TYPE..ADD VALUE" directive is emitted,
        which must be run outside of a transaction block at the database level.
        The :meth:`.MigrationContext.autocommit_block` method makes use of the
        SQLAlchemy ``AUTOCOMMIT`` isolation level setting, which against the
        psycogp2 DBAPI corresponds to the ``connection.autocommit`` setting,
        to ensure that the database driver is not inside of a DBAPI level
        transaction block.

        .. warning::

            As is necessary, **the database transaction preceding the block is
            unconditionally committed**.  This means that the run of migrations
            preceding the operation will be committed, before the overall
            migration operation is complete.

            It is recommended that when an application includes migrations with
            "autocommit" blocks, that
            :paramref:`.EnvironmentContext.transaction_per_migration` be used
            so that the calling environment is tuned to expect short per-file
            migrations whether or not one of them has an autocommit block.


        .. versionadded:: 1.2.0

        N�
AUTOCOMMIT)�isolation_level)�_in_connection_transactionr�r^r]�emit_commitr>rFrU�get_isolation_level�execution_options�begin�
emit_begin)r8r��
current_level�base_connection�
fake_transs     r9�autocommit_blockz!MigrationContext.autocommit_blocks�����^&*�%D�%D�%F�%F�"��9�&�	%�4�;�	%��I�!�!�#�#�#�#�
'�	%��$�0�0�0���$�$�&�&�&� $�D���{�	��?�.�.�.� �O�?�?�A�A�M�"�o�O� �1�1�,�1�O�O�
P�D�O��	�$�
15��0E�0E�0G�0G�J�J��J�	<��E�E�E��;�
I���2�2�2��)��%�%�'�'�'���1�1�$1�2����:I�H���$�)�"6��y�*�
<�t�{�
<��	�$�$�&�&�&�&�&�+�
<���2�2�2�$(�O�$9�$9�$;�$;��!�!�!�
<�
<���;�
I���2�2�2��)��%�%�'�'�'���1�1�$1�2����:I�H���$�)�"6��y�*�
<�t�{�
<��	�$�$�&�&�&�&�+�
<���2�2�2�$(�O�$9�$9�$;�$;��!�;�;�;�;s
�#F�B,IF�_per_migration�bool�.Union[_ProxyTransaction, ContextManager[None]]c� ���jrt��S�jjr|�jk}n|du}|st��S�jjsh|sJ��jrt��S�jdu}|rt��S�j�J�tj	�j���_t���S�jrt�fd���}|��S�j�J�tj	�j���_t���S)a�Begin a logical transaction for migration operations.

        This method is used within an ``env.py`` script to demarcate where
        the outer "transaction" for a series of migrations begins.  Example::

            def run_migrations_online():
                connectable = create_engine(...)

                with connectable.connect() as connection:
                    context.configure(
                        connection=connection, target_metadata=target_metadata
                    )

                    with context.begin_transaction():
                        context.run_migrations()

        Above, :meth:`.MigrationContext.begin_transaction` is used to demarcate
        where the outer logical transaction occurs around the
        :meth:`.MigrationContext.run_migrations` operation.

        A "Logical" transaction means that the operation may or may not
        correspond to a real database transaction.   If the target database
        supports transactional DDL (or
        :paramref:`.EnvironmentContext.configure.transactional_ddl` is true),
        the :paramref:`.EnvironmentContext.configure.transaction_per_migration`
        flag is not set, and the migration is against a real database
        connection (as opposed to using "offline" ``--sql`` mode), a real
        transaction will be started.   If ``--sql`` mode is in effect, the
        operation would instead correspond to a string such as "BEGIN" being
        emitted to the string output.

        The returned object is a Python context manager that should only be
        used in the context of a ``with:`` statement as indicated above.
        The object has no other guaranteed API features present.

        .. seealso::

            :meth:`.MigrationContext.autocommit_block`

        TNc3�x�K��j���dV��j���dSr7)r�r�r�r?s�r9�begin_commitz8MigrationContext.begin_transaction.<locals>.begin_commit�s>������	�$�$�&�&�&������	�%�%�'�'�'�'�'r;)rvrr�r^rsr]r>rUr �"_safe_begin_connection_transactionr1r)r8r��transaction_now�in_transactionr�s`    r9�begin_transactionz"MigrationContext.begin_transactionwsN���X�(�	!��=�=� ��9�&�	5�,��0O�O�O�O�,��4�O��.	+��=�=� ���,�+	+�!�!�!�>��{�
3�"�}�}�$�"&�!2�$�!>��!�	3�&�=�=�(��?�6�6�6�#�F� �O����%�
-�T�2�2�2�
�[�	+�
�
(�
(�
(�
(��^�
(�
 �<�>�>�!��?�.�.�.� +� N���!�!�D��%�T�*�*�*r;c���|���}t|��dkrdSt|��dkrtjd|jz���|dS)a�Return the current revision, usually that which is present
        in the ``alembic_version`` table in the database.

        This method intends to be used only for a migration stream that
        does not contain unmerged branches in the target database;
        if there are multiple branches present, an exception is raised.
        The :meth:`.MigrationContext.get_current_heads` should be preferred
        over this method going forward in order to be compatible with
        branch migration support.

        If this :class:`.MigrationContext` was configured in "offline"
        mode, that is with ``as_sql=True``, the ``starting_rev``
        parameter is returned instead, if any.

        rNr(zQVersion table '%s' has more than one head present; please use get_current_heads())�get_current_heads�lenrr�rg�r8�headss  r9�get_current_revisionz%MigrationContext.get_current_revision�si�� �&�&�(�(���u�:�:��?�?��4�
��Z�Z�!�^�^��#�1�37�3E�F���
�
��8�Or;�Tuple[str, ...]c����jrO�j}|dkrd}n)|�'�jr �fd�tj|��D��}tj|d���S�jrtjd�������sdS�j�J�td��j�
�j�����D����S)a�Return a tuple of the current 'head versions' that are represented
        in the target database.

        For a migration stream without branches, this will be a single
        value, synonymous with that of
        :meth:`.MigrationContext.get_current_revision`.   However when multiple
        unmerged branches exist within the target database, the returned tuple
        will contain a value for each head.

        If this :class:`.MigrationContext` was configured in "offline"
        mode, that is with ``as_sql=True``, the ``starting_rev``
        parameter is returned in a one-length tuple.

        If no version table is present, or if there are no revisions
        present, an empty tuple is returned.

        �baseNc�r��g|]3}|dv�td�j�|����j��4S))Nr�r+)rr\�get_revision�revision)�.0�sfrr8s  �r9�
<listcomp>z6MigrationContext.get_current_heads.<locals>.<listcomp>sK���"�"�"���.�0�0���4�;�#;�#;�C�#@�#@�A�A�J�0�0�0r;rH��defaultzECan't specify current_rev to context when using a database connectionc3�&K�|]}|dV��
dS)rNrH)r��rows  r9�	<genexpr>z5MigrationContext.get_current_heads.<locals>.<genexpr>s7����
�
��C��F�
�
�
�
�
�
r;)
r]rr\r�to_list�to_tupler��_has_version_tablerU�tuple�executer}�select)r8�start_from_revs` r9r�z"MigrationContext.get_current_heads�s���$�;�	�"&�"6�N���'�'�!%����+���+�"�"�"�"�#�|�N�;�;�"�"�"��
�=���<�<�<�<��#�
��'�7�����*�*�,�,�
��r���*�*�*��
�
�"�o�5�5�d�m�6J�6J�6L�6L�M�M�
�
�
�
�
�	
r;rbc�6�tj|j��5|j�J�|j�|jd���|r:|j�J�|j�|j�����ddd��dS#1swxYwYdS)NT)�
checkfirst)r �_ensure_scope_for_ddlrUr}�creater��delete)r8rbs  r9�_ensure_version_tablez&MigrationContext._ensure_version_table!s���
�
.�t��
?�
?�	@�	@��?�.�.�.��M� � ���T� �B�B�B��
@���2�2�2���'�'��
�(<�(<�(>�(>�?�?�?�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�	@�	@s�A'B�B�Bc�^�|j�J�tj|j|j|j��Sr7)rUr �_connectable_has_tablergrir?s r9r�z#MigrationContext._has_version_table)s4����*�*�*��1��O�T�/��1J�
�
�	
r;�script_directoryr,r��strc���|���}|js|s|���t||��}|�||��D]}|�|���dS)a\Stamp the version table with a specific revision.

        This method calculates those branches to which the given revision
        can apply, and updates those branches as though they were migrated
        towards that revision (either up or down).  If no current branches
        include the revision, it is added as a new branch head.

        N)r�r]r��HeadMaintainer�_stamp_revs�update_to_step)r8r�r�r��head_maintainer�steps      r9�stampzMigrationContext.stamp/s����&�&�(�(���{�	)�5�	)��&�&�(�(�(�(��u�5�5��$�0�0��5�A�A�	1�	1�D��*�*�4�0�0�0�0�	1�	1r;�kwrc
��|j���|jr4|jrt	jd���|�d���d}nN|���}|j�	dd��}|js|s|s|���t||��}|j�J�|�||��D]�}|�d���5|jr/|j
s(|j�J�|j�|j��t"�d	|��|jr"|j�d
|j����|jdi|��|�|��|jD](}|||jt1|j
��|����)	ddd��n#1swxYwY��|jr1|j
s,|j�J�|j�|j��dSdSdS)a-Run the migration scripts established for this
        :class:`.MigrationContext`, if any.

        The commands in :mod:`alembic.command` will set up a function
        that is ultimately passed to the :class:`.MigrationContext`
        as the ``fn`` argument.  This function represents the "work"
        that will be done when :meth:`.MigrationContext.run_migrations`
        is called, typically from within the ``env.py`` script of the
        migration environment.  The "work function" then provides an iterable
        of version callables and other version information which
        in the case of the ``upgrade`` or ``downgrade`` commands are the
        list of version scripts to invoke.  Other commands yield nothing,
        in the case that a command wants to run some other operation
        against the database such as the ``current`` or ``stamp`` commands.

        :param \**kw: keyword arguments here will be passed to each
         migration callable, that is the ``upgrade()`` or ``downgrade()``
         method within revision scripts.

        z!Can't use --purge with --sql modeT)rbrH�dont_mutateFN)r�z
Running %sz-- Running )�ctxr�r��run_args)r��start_migrationsrbr]rr�r�r�rWrrr�rxr�r�rUr}r�r�r��
static_output�	short_log�migration_fnr�rt�set�drop)r8r�r�r�r�r��callbacks       r9�run_migrationszMigrationContext.run_migrations?s���*	
�	�"�"�$�$�$��:�	-��{�
M��'�(K�L�L�L��&�&�T�&�2�2�2��E�E��*�*�,�,�E��)�-�-�
�u�=�=�K��;�
-�u�
-�[�
-��*�*�,�,�,�(��u�5�5���"�.�.�.��'�'��t�4�4�	�	�D��'�'�t�'�<�<�
�
��;�:��'<�:� �?�6�6�6��M�(�(���9�9�9�����t�,�,�,��;���I�+�+�+�+/�>�>�;����"��!�'�'�B�'�'�'� �.�.�t�4�4�4� $� ?���H��H� �!�Y�!�/�"7�8�8�!#�	������)
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��8�;�	0��4�	0��?�.�.�.��M���t��/�/�/�/�/�	0�	0�	0�	0s�*C
G�G	�G	c�R�	|jj}|��S#t$rYdSwxYw�NF)rUr��AttributeError)r8�meths  r9r�z+MigrationContext._in_connection_transaction�sB��	��?�1�D��4�6�6�M���	�	�	��5�5�	���s��
&�&�sql�Union[ClauseElement, str]r��Optional[dict]c�<�|j�||��dS)aExecute a SQL construct or string statement.

        The underlying execution mechanics are used, that is
        if this is "offline mode" the SQL is written to the
        output buffer, otherwise the SQL is emitted on
        the current SQLAlchemy connection.

        N�r��_exec)r8r�r�s   r9r�zMigrationContext.execute�s!��	
�	����.�/�/�/�/�/r;r&c�B���fd�}tj�j|��S)Nc�<���j�|��dSr7r�)�	construct�multiparams�paramsr8s   �r9�dumpz1MigrationContext._stdout_connection.<locals>.dump�s����I�O�O�I�&�&�&�&�&r;)rr&rT)r8rUr�s`  r9ruz#MigrationContext._stdout_connection�s3���	'�	'�	'�	'�	'�"�0���t�D�D�Dr;c��|jS)a�Return the current "bind".

        In online mode, this is an instance of
        :class:`sqlalchemy.engine.Connection`, and is suitable
        for ad-hoc execution of any kind of usage described
        in SQLAlchemy Core documentation as well as
        for usage with the :meth:`sqlalchemy.schema.Table.create`
        and :meth:`sqlalchemy.schema.MetaData.create_all` methods
        of :class:`~sqlalchemy.schema.Table`,
        :class:`~sqlalchemy.schema.MetaData`.

        Note that when "standard output" mode is enabled,
        this bind will be a "mock" connection handler that cannot
        return results and is only appropriate for a very limited
        subset of commands.

        )rUr?s r9�bindzMigrationContext.bind�s��&��r;�Optional[Config]c�,�|jr|jjSdS)zLReturn the :class:`.Config` used by the current environment,
        if any.N)rY�configr?s r9r�zMigrationContext.config�s ��
�#�	��+�2�2��4r;�inspector_column�Column[Any]�metadata_columnrc���|jdurdSt|j��r'|�||||j|j��}|�|S|j�||��Sr�)r{�callable�typer�re)r8r�r��
user_values    r9�
_compare_typezMigrationContext._compare_type�s{���"�e�+�+��5��D�+�,�,�		"��0�0�� �� �%��$���J��%�!�!��y�%�%�&6��H�H�Hr;�rendered_metadata_default�rendered_column_defaultc��|jdurdSt|j��r#|�|||||j|��}|�|S|j�||||��Sr�)r|r�server_defaultr�rf)r8r�r�rrrs      r9�_compare_server_defaultz(MigrationContext._compare_server_default�s����,��5�5��5��D�5�6�6�
	"��:�:�� ��'��.�)�
��J��%�!�!��y�/�/���%�#�	
�
�	
r;r7)
rTr"rUrVrWrXrYrZr4r5)NNNNNNN)rUrVrr�r�r�rTr�rYrZr�r�rWr�r4r3)r4r�)F)r�r�r4r�)r4r��r4r�)rbr�r4r5�r4r�)r�r,r�r�r4r5�r�rr4r5)r�r�r�r�r4r5)rUrVr4r&)r4rV)r4r�)r�r�r�rr4r�)
r�r�r�r�rr�rr�r4r�)rOrPrQ�__doc__r:�classmethodr�rr�r�r�r�r�r�r�r�r�r�rurRr�r�rr	rHr;r9r3r3Us
������-�-�h=A�W
�W
�W
�W
�W
�r�,0�)-�&*�%)�<@�15�"�5P�5P�5P�5P��[�5P�n�]<�]<�]<��^�]<�@&+�b+�b+�b+�b+�b+�H����6)
�)
�)
�)
�V@�@�@�@�@�
�
�
�
�1�1�1�1� G0�G0�G0�G0�R����-1�
0�
0�
0�
0�
0�E�E�E�E������X��(�����X��I�I�I�I�&
�
�
�
�
�
r;r3c�6�eZdZdd�Zdd
�Zdd�Zdd�Zdd�ZdS)r��contextr3r�rr4r5c�<�||_t|��|_dSr7)rr�r�)r8rr�s   r9r:zHeadMaintainer.__init__�s�������Z�Z��
�
�
r;�versionr�c��||jvsJ�|j�|��|jj�|jj����td|z�������dS)N�'%s'�rj)	r��addrr�r�r}�insert�valuesr)r8rs  r9�_insert_versionzHeadMaintainer._insert_version�s����d�j�(�(�(�(��
���w����������L�!�(�(�*�*�1�1�*�6�G�+;�<�<�
2�
�
�	
�	
�	
�	
�	
r;c	���|j�|��|jj�|jj����|jjjj	td|z��k����}|jjsG|jjj
r8|�8|jdkr/tjd||jj|jfz���dSdSdSdS)Nrr(zOOnline migration expected to match one row when deleting '%s' in '%s'; %d found)r��removerr�r�r}r��where�crjrr]rT�supports_sane_rowcount�rowcountrr�rg)r8r�rets   r9�_delete_versionzHeadMaintainer._delete_versions���
���'�"�"�"��l��%�%��L�!�(�(�*�*�0�0���%�'�3�!�&�7�"2�3�3�4�
�
�
�
����#�	���$�;�	������!�!��#���D�L�6���E�F���
�
	�	�	�	� ��!�!r;�from_�to_c	�l�||jvsJ�|j�|��|j�|��|jj�|jj����td|z������
|jjjjtd|z��k����}|jj
sH|jjjr9|�9|jdkr0t#jd|||jj|jfz���dSdSdSdS)Nrrr(zWOnline migration expected to match one row when updating '%s' to '%s' in '%s'; %d found)r�rrrr�r�r}�updaterrrrrjr]rTrrrr�rg)r8r"r#r s    r9�_update_versionzHeadMaintainer._update_versionsB���$�*�$�$�$�$��
���%� � � ��
���s�����l��%�%��L�!�(�(�*�*�
�V��v��|� <� <�V�
=�
=�
�U���%�'�3�!�&�5�.�1�1�2���
�
����#�	���$�;�	������!�!��#���#�t�|�9�3�<�H�I���
�
	�	�	�	� ��!�!r;r��Union[RevisionStep, StampStep]c��|�|j��r9|j}t�d|��|�|��dS|�|j��r9|j}t�d|��|�|��dS|�	|j��rm|�
|j��\}}}t�d|||��|D]}|�|���|�||��dS|�|j��rm|�
|j��\}}}t�d|||��|D]}|�|���|�||��dS|�|j��\}	}
t�d|	|
��|�|	|
��dS)Nzbranch delete %sznew branch insert %sz!merge, delete %s, update %s to %sz#unmerge, insert %s, update %s to %szupdate %s to %s)�should_delete_branchr��delete_version_numr��debugr!�should_create_branch�insert_version_numr�should_merge_branches�merge_branch_identsr&�should_unmerge_branches�unmerge_branch_idents�update_version_num)r8r��vers�delete_revs�update_from_rev�
update_to_rev�delrev�insert_revs�insrevr"r#s           r9r�zHeadMaintainer.update_to_step9s.���$�$�T�Z�0�0�*	-��*�D��I�I�(�$�/�/�/�� � ��&�&�&�&�&�
�
&�
&�t�z�
2�
2�&	-��*�D��I�I�,�d�3�3�3�� � ��&�&�&�&�&�
�
'�
'��
�
3�
3�"	-��(�(���4�4�	
�����I�I�3����	
�
�
�&�
-�
-���$�$�V�,�,�,�,�� � ��-�@�@�@�@�@�
�
)�
)�$�*�
5�
5�	-�
�*�*�4�:�6�6�	
�����I�I�5����	
�
�
�&�
-�
-���$�$�V�,�,�,�,�� � ��-�@�@�@�@�@��0�0���<�<�J�E�3��I�I�'���4�4�4�� � ���,�,�,�,�,r;N)rr3r�rr4r5)rr�r4r5)r"r�r#r�r4r5)r�r'r4r5)rOrPrQr:rr!r&r�rHr;r9r�r��sx������ � � � �
�
�
�
�����.����6+-�+-�+-�+-�+-�+-r;r�c�$�eZdZUdZded<	ded<	ded<	ded<	ded	<	d
ed<	dd�Zedd���Zedd���Zedd���Z	ed d���Z
ed!d���Zed!d���Zed!d���Z
ed!d���ZdS)"�
MigrationInfoz�Exposes information about a migration step to a callback listener.

    The :class:`.MigrationInfo` object is available exclusively for the
    benefit of the :paramref:`.EnvironmentContext.on_version_apply`
    callback hook.

    r��
is_upgrade�is_stampr��up_revision_idr��up_revision_ids�down_revision_idsr/�revision_map�up_revisions�Union[str, Tuple[str, ...]]�down_revisionsr4r5c���||_||_||_tj|d���|_|jr|jd|_nd|_tj|d���|_dS)NrHr�r)rAr<r=rr�r?r>r@)r8rAr<r=rBrDs      r9r:zMigrationInfo.__init__�sv��)���$��� ��
�#�}�\�2�F�F�F�����	'�"&�"6�q�"9�D���
#'�D��!%��~�r�!J�!J�!J����r;c��|jS)aTrue/False: indicates whether this operation is a migration.

        At present this is true if and only the migration is not a stamp.
        If other operation types are added in the future, both this attribute
        and :attr:`~.MigrationInfo.is_stamp` will be false.
        )r=r?s r9�is_migrationzMigrationInfo.is_migration�s���=� � r;c�,�|jr|jn|jS)z7Active revisions before this migration step is applied.)r<r@r?r?s r9�source_revision_idsz!MigrationInfo.source_revision_ids�s��'+�o�O�D�"�"�4�;O�	
r;c�,�|jr|jn|jS)z6Active revisions after this migration step is applied.)r<r?r@r?s r9�destination_revision_idsz&MigrationInfo.destination_revision_ids�s��%)�O�O�D� � ��9O�	
r;�Optional[Revision]c�@�|j�|j��S)zUGet :attr:`~.MigrationInfo.up_revision_id` as
        a :class:`.Revision`.

        )rAr�r>r?s r9�up_revisionzMigrationInfo.up_revision�s��� �-�-�d�.A�B�B�Br;�%Tuple[Optional[_RevisionOrBase], ...]c�@�|j�|j��S)zLGet :attr:`~.MigrationInfo.up_revision_ids` as a
        :class:`.Revision`.)rA�
get_revisionsr?r?s r9rBzMigrationInfo.up_revisions�s��� �.�.�t�/C�D�D�Dr;c�@�|j�|j��S)zcGet :attr:`~.MigrationInfo.down_revision_ids` as a tuple of
        :class:`Revisions <.Revision>`.)rArQr@r?s r9rDzMigrationInfo.down_revisions�s��� �.�.�t�/E�F�F�Fr;c�@�|j�|j��S)zdGet :attr:`~MigrationInfo.source_revision_ids` as a tuple of
        :class:`Revisions <.Revision>`.)rArQrIr?s r9�source_revisionszMigrationInfo.source_revisions�s��� �.�.�t�/G�H�H�Hr;c�@�|j�|j��S)ziGet :attr:`~MigrationInfo.destination_revision_ids` as a tuple of
        :class:`Revisions <.Revision>`.)rArQrKr?s r9�destination_revisionsz#MigrationInfo.destination_revisions�s��� �.�.�t�/L�M�M�Mr;N)rAr/r<r�r=r�rBrCrDrCr4r5rr
)r4rL)r4rO)rOrPrQr
�__annotations__r:rRrGrIrKrNrBrDrTrVrHr;r9r;r;gs����������������N�N�N�6�"�!�!�!��%�$�$�$��'�&�&�&������A�K�K�K�K�*�!�!�!��X�!��
�
�
��X�
��
�
�
��X�
��C�C�C��X�C��E�E�E��X�E�
�G�G�G��X�G�
�I�I�I��X�I�
�N�N�N��X�N�N�Nr;r;c��eZdZUded<ded<ded<ded<edd
���Zedd���Zedd���Zedd���Z	edd���Z
d�ZdS)�
MigrationStepr��from_revisions_no_deps�to_revisions_no_depsr�r<rr�r4r�c��|jjSr7)r�rOr?s r9rozMigrationStep.name�s��� �)�)r;rAr/r\r+�RevisionStepc�$�t||d��S)NT�r]�r�rAr\s   r9�upgrade_from_scriptz!MigrationStep.upgrade_from_script�s���L�&�$�7�7�7r;c�$�t||d��Sr�r_r`s   r9�downgrade_from_scriptz#MigrationStep.downgrade_from_script�s���L�&�%�8�8�8r;c��|jSr7)r<r?s r9�is_downgradezMigrationStep.is_downgrades
���?�"�"r;c�|�|j�dtj|j���dtj|j����S)N� � -> )ror�format_as_commarZr[r?s r9r�zMigrationStep.short_logsB��
�I�I�I�� ��!<�=�=�=�=�� ��!:�;�;�;�
�	
r;c��|jrE|j�dtj|j���dtj|j���d|j��S|jS)Nrgrhz, )�docrorrirZr[r�r?s r9�__str__zMigrationStep.__str__
s^���8�	"��	�	�	��$�T�%@�A�A�A�A��$�T�%>�?�?�?�?����	�
��>�!r;N�r4r�)rAr/r\r+r4r]r)rOrPrQrWrRrorrarcrer�rlrHr;r9rYrY�s��������+�+�+�+�)�)�)�)���������
�*�*�*��X�*��8�8�8��[�8�
�9�9�9��[�9�
�#�#�#��X�#��
�
�
��X�
�	"�	"�	"�	"�	"r;rYc�<�eZdZd)d	�Zd
�Zd*d
�Zed+d���Zed,d���Zed,d���Z	ed,d���Z
ed,d���Zed-d���Zd.d�Z
d/d�Zd0d�Zd1d�Zd.d�Zd.d �Zd.d!�Zd2d#�Zed+d$���Zed+d%���Zed3d'���Zd(S)4r]rAr/r�r+r<r�r4r5c�|�||_||_||_|r|jj|_dS|jj|_dSr7)rAr�r<�module�upgrader��	downgrade)r8rAr�r<s    r9r:zRevisionStep.__init__sP��)��� ��
�$����	���'�
����
��)�
���r;c�2�d|jj�d|j�d�S)Nz
RevisionStep(z
, is_upgrade=�))r�r<r?s r9�__repr__zRevisionStep.__repr__)s%����M�"�"�"��O�O�O�
�	
r;�other�objectc�l�t|t��o|j|jko|j|jkSr7)r�r]r�r<�r8rvs  r9�__eq__zRevisionStep.__eq__/s7���u�l�+�+�
4���$�-�/�
4���5�#3�3�	
r;r�c��|jjSr7)r�rkr?s r9rkzRevisionStep.doc6s
���}� � r;r�c�B�|jr|jjS|jjfSr7�r<r��_normalized_down_revisionsr?s r9�from_revisionszRevisionStep.from_revisions:s%���?�	-��=�;�;��M�*�,�,r;c�B�|jr|jjS|jjfSr7�r<r��_versioned_down_revisionsr?s r9rZz#RevisionStep.from_revisions_no_depsAs'���?�	-��=�:�:��M�*�,�,r;c�B�|jr
|jjfS|jjSr7r}r?s r9�to_revisionszRevisionStep.to_revisionsJs%���?�	<��M�*�,�,��=�;�;r;c�B�|jr
|jjfS|jjSr7r�r?s r9r[z!RevisionStep.to_revisions_no_depsQs'���?�	;��M�*�,�,��=�:�:r;c�<�t|jj��dkS�Nr()r�r�r~r?s r9�_has_scalar_down_revisionz&RevisionStep._has_scalar_down_revisionZs���4�=�;�<�<��A�Ar;r��Set[str]c��|jsdS|jj|vrdS|jj}|sdS|�|��}|S)z�A delete is when we are a. in a downgrade and b.
        we are going to the "base" or we are going to a version that
        is implied as a dependency on another version that is remaining.

        FT)rer�r~�_unmerge_to_revisions)r8r��downrevsr�s    r9r)z!RevisionStep.should_delete_branch^s^��� �	��5��=�!��.�.��5��=�;���	$��4� �5�5�e�<�<�L�#�#�#r;�Tuple[List[str], str, str]c��t|���|j��}|rsd�|j�|j�|��d���D��}t
t|j���|����}nt
|j��}t
|dd���|d|jdfS)Nc��h|]	}|j��
SrH�r��r��rs  r9�	<setcomp>z3RevisionStep.merge_branch_idents.<locals>.<setcomp>{�*�������
���r;F��checkr���)r��
differencerrA�_get_ancestor_nodesrQ�listr�)r8r��other_heads�	ancestorsrs     r9r/z RevisionStep.merge_branch_identsus����%�j�j�+�+�D�,?�@�@���	7����*�>�>��%�3�3�K�@�@��?������I�"��D�'�(�(�3�3�I�>�>���N�N�"�$�"5�6�6�N�
���"��%�&�&��2����a� �	
�	
r;�Collection[str]c�R�t|���|jjg��}|rrd�|j�|j�|��d���D��}t
t|j���|����S|jS)Nc��h|]	}|j��
SrHr�r�s  r9r�z5RevisionStep._unmerge_to_revisions.<locals>.<setcomp>�r�r;Fr�)r�r�r�rAr�rQr�r�)r8r�r�r�s    r9r�z"RevisionStep._unmerge_to_revisions�s����%�j�j�+�+�T�]�-C�,D�E�E���		%����*�>�>��%�3�3�K�@�@��?������I���T�.�/�/�:�:�9�E�E�F�F�F��$�$r;� Tuple[str, str, Tuple[str, ...]]c�h�|�|��}|jd|d|dd�fS�Nrr�)r�r)r8r�r�s   r9r1z"RevisionStep.unmerge_branch_idents�sB���1�1�%�8�8��
���"������2���	
�	
r;c�f�|jsdS|jj}|sdS|�|��sdSdS)NFT)r<r�r~�intersection�r8r�r�s   r9r,z!RevisionStep.should_create_branch�sJ����	��5��=�;���	��4��%�%�h�/�/�
��t��ur;c��|jsdS|jj}t|��dkr(t|�|����dkrdSdS�NFr(T)r<r�r~r�r�r�s   r9r.z"RevisionStep.should_merge_branches�sV����	��5��=�;���x�=�=�1����U�%7�%7��%A�%A�!B�!B�Q�!F�!F��4��ur;c�v�|jsdS|jj}|jj|vrt|��dkrdSdSr�)rer�r~r�r�s   r9r0z$RevisionStep.should_unmerge_branches�sF��� �	��5��=�;���=�!�U�*�*�s�8�}�}�q�/@�/@��4��ur;�Tuple[str, str]c��|jsR|�|jj��}t	|��dks
Jd���t|��d}n|jjd}|jr||jjfS|jj|fS)Nr(z4Can't do an UPDATE because downrevision is ambiguousr)r�r�r�r~r�r�r<)r8r��downrev�
down_revisions    r9r2zRevisionStep.update_version_num�s����-�		H��(�(��
�8���G��G����!�!�!�E�"�!�!� ��M�M�!�,�M�M� �M�D�Q�G�M��?�	9� �$�-�"8�8�8��=�)�=�8�8r;c��|jjSr7r�r?s r9r*zRevisionStep.delete_version_num��
���}�%�%r;c��|jjSr7r�r?s r9r-zRevisionStep.insert_version_num�r�r;r;c�f�t|j|jj|jj|jd���S)NF�rArBrDr<r=)r;rAr�r~r<r?s r9r�zRevisionStep.info�s7����*���/��=�C����
�
�
�	
r;N)rAr/r�r+r<r�r4r5)rvrwr4r�rmr
r�r�r�r4r�)r�r�r4r�)r�r�r4r�)r�r�r4r��r�r�r4r��r4r;)rOrPrQr:rurzrRrkrrZr�r[r�r)r/r�r1r,r.r0r2r*r-r�rHr;r9r]r]s������
�
�
�
�
�
�
�
�
�
�
��!�!�!��X�!��-�-�-��X�-��-�-�-��X�-��<�<�<��X�<��;�;�;��X�;��B�B�B��X�B�$�$�$�$�.
�
�
�
�2%�%�%�%�

�

�

�

�����&	�	�	�	�	�	�	�	�9�9�9�9�"�&�&�&��X�&��&�&�&��X�&��
�
�
��X�
�
�
r;r]c��eZdZU	d+d,d�ZdZd
ed<d-d�Zd�Zed���Z	ed.d���Z
ed.d���Zed.d���Zed/d���Z
ed/d���Zd0d�Zd1d!�Zd2d#�Zd3d$�Zd4d&�Zd3d'�Zd3d(�Zed5d*���ZdS)6�	StampStepNr"�%Optional[Union[str, Collection[str]]]r#r<r��branch_moverA�Optional[RevisionMap]r4r5c��tj|d���|_tj|d���|_||_||_|j|_||_dS)NrHr�)	rr�r"r#r<r��stamp_revisionr�rA)r8r"r#r<r�rAs      r9r:zStampStep.__init__�sX��'+�m�E�2�&F�&F�&F��
�$(�M�#�r�$B�$B�$B���$���&��� �/���(����r;r�rkr�rc��dSr7rH)r8r�s  r9r�zStampStep.stamp_revisions���tr;c��t|t��o?|j|jko/|j|jko|j|jko|j|jkSr7)r�r�r�	revisionsr�r�r<rys  r9rzzStampStep.__eq__	sb���u�i�(�(�
4��$���6�
4��"�d�&7�7�
4��!�T�%5�5�
4���5�#3�3�	
r;c��|jSr7�r"r?s r9rzStampStep.from_revisionss
���z�r;r�c��|jSr7�r#r?s r9r�zStampStep.to_revisionss	���x�r;c��|jSr7r�r?s r9rZz StampStep.from_revisions_no_depss���z�r;c��|jSr7r�r?s r9r[zStampStep.to_revisions_no_deps s���x�r;r�c�P�t|j��dksJ�|jdS�Nr(r�r�r"r?s r9r*zStampStep.delete_version_num&s'���4�:���!�#�#�#�#��z�!�}�r;c�P�t|j��dksJ�|jdSr��r�r#r?s r9r-zStampStep.insert_version_num+s'���4�8�}�}��!�!�!�!��x��{�r;r�r�r�c��t|j��dksJ�t|j��dksJ�|jd|jdfSr�)r�r"r#r�s  r9r2zStampStep.update_version_num0sK���4�:���!�#�#�#�#��4�8�}�}��!�!�!�!��z�!�}�d�h�q�k�)�)r;�Union[Set[str], List[str]]�=Union[Tuple[List[Any], str, str], Tuple[List[str], str, str]]c�l�t|jdd���|jd|jdfSr�)r�r"r#r�s  r9r/zStampStep.merge_branch_idents5s6��

���A�b�D�!�"�"��J�r�N��H�Q�K�	
�	
r;�Tuple[str, str, List[str]]c�l�|jd|jdt|jdd���fSr�)r"r#r�r�s  r9r1zStampStep.unmerge_branch_idents?s5��

�J�q�M��H�R�L����!�B�$�� � �	
�	
r;c��|jo|jSr7)rer�r�s  r9r)zStampStep.should_delete_branchIs��� �5�T�%5�5r;�Union[Set[str], bool]c��|joT|jp&t|j���|��o&t|j���|��Sr7)r<r�r�r"r�r#r�s  r9r,zStampStep.should_create_branchOsP���O�
0��!�F�S���_�_�%?�%?��%F�%F�
0��D�H�
�
�(�(��/�/�	
r;c�2�t|j��dkSr�r�r�s  r9r.zStampStep.should_merge_branchesVs���4�:����"�"r;c�2�t|j��dkSr�r�r�s  r9r0z!StampStep.should_unmerge_branchesYs���4�8�}�}�q� � r;r;c��|jr|j|jfn
|j|jf\}}|j�J�t	|j|||jd���S)NTr�)r<r#r"rAr;)r8�up�downs   r9r�zStampStep.info\sm����
(�T�X�t�z�"�"��*�d�h�'�	��D�
� �,�,�,���*������
�
�
�	
r;r7)r"r�r#r�r<r�r�r�rAr�r4r5rr
rmr�)r�r�r4r�)r�r�r4r�r�)r�r�r4r�r�)rOrPrQr:rkrWr�rzrRrr�rZr[r*r-r2r/r1r)r,r.r0r�rHr;r9r�r��s��������/3�

)�
)�
)�
)�
)��C���������
�
�
�����X�������X�������X��
�����X��
�����X�������X��*�*�*�*�

�
�
�
�
�
�
�
�6�6�6�6�
�
�
�
�#�#�#�#�!�!�!�!��

�

�

��X�

�

�

r;r�)G�
__future__r�
contextlibrr�loggingry�typingrrrr	r
rrr
rrrrrr�
sqlalchemyrrrrrr�sqlalchemy.enginerrr��sqlalchemy.engine.strategiesr�rrr �util.compatr!r"r#�sqlalchemy.engine.baser$r%�sqlalchemy.engine.mockr&�sqlalchemy.sql.elementsr'�environmentr)r�r*�script.baser+r,�script.revisionr-r.r/�	getLoggerrOr�r1r3r�r;rYr]r�rHr;r9�<module>r�s���"�"�"�"�"�"�%�%�%�%�%�%�"�"�"�"�"�"�����
�
�
�
�������������������������!�!�!�!�!�!������������������������������������������� � � � � � �������������%�%�%�%�%�%�������+�+�+�+�+�+�������������$�$�$�$�$�$�-�-�-�-�-�-�;�;�;�;�;�;�������������������#�#�#�#�#�#��.�)�)�)�)�)�)�%�%�%�%�%�%�1�1�1�1�1�1�2�2�2�2�2�2�5�5�5�5�5�5�5�5�5�5�5�5�/�/�/�/�/�/�������$�$�$�$�$�$�-�-�-�-�-�-�1�1�1�1�1�1�*�*�*�*�*�*�-�-�-�-�-�-��g���!�!��7�7�7�7�7�7�7�7�:`

�`

�`

�`

�`

�`

�`

�`

�Fl-�l-�l-�l-�l-�l-�l-�l-�^@N�@N�@N�@N�@N�@N�@N�@N�F,"�,"�,"�,"�,"�,"�,"�,"�^X
�X
�X
�X
�X
�=�X
�X
�X
�vv
�v
�v
�v
�v
�
�v
�v
�v
�v
�v
r;

Hacked By AnonymousFox1.0, Coded By AnonymousFox