
    gr             
      
   S SK Jr  S SKJr  S SKrS SKJr  S SKJr  S SKJr  S SKJ	r	  S SKJ
r
  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  \(       a  S SKJr  S SK J!r!  S SK"J#r#  S SK"J$r$  S S K"J%r%  S S!K"J&r&  S S"K'J(r(  S S#K)J*r*  S S$K)J+r+  S S%K)J,r,  S S&K)J-r-  S S'K)J.r.  S S(K)J/r/  S S)K)J0r0  S S*K)J1r1  S S+K)J2r2  S S,K)J3r3  S S-K)J4r4  S S.K)J5r5  S S/K6J7r7  S S0K8J9r9  SS1K:J;r;  SS2K<J=r=  SS3K>J?r?  \" S4\S59r@\" S6S7S59rA " S8 S95      rB " S: S7\B5      rC\R                  " S;5      \R                  " S;S<5       " S= S>\B5      5       5       rE\R                  " S?5      \R                  " S?S@5      \CR                  SA5       " SB SC\C5      5       5       5       rG\R                  " SD5      \R                  " SDSE5      \CR                  SF5       " SG SH\C5      5       5       5       rH\R                  " SI5      \R                  " SISJ5      \CR                  SK5       " SL SM\C5      5       5       5       rI\R                  " SN5      \R                  " SNSO5      \CR                  SP5      \CR                  SQ5      \CR                  SR5       " SS ST\C5      5       5       5       5       5       rJ\R                  " SU5      \R                  " SUSV5       " SW SX\B5      5       5       rK\R                  " SY5      \R                  " SYSZ5       " S[ S\\B5      5       5       rL\R                  " S]5       " S^ S_\B5      5       rM\R                  " S`5       " Sa Sb\B5      5       rN " Sc Sd\B5      rO\R                  " Se5       " Sf Sg\O5      5       rP\R                  " Sh5      \R                  " ShSi5       " Sj Sk\O5      5       5       rQ\R                  " Sl5      \R                  " SlSm5       " Sn So\O5      5       5       rR\R                  " Sp5      \R                  " SpSq5       " Sr Ss\O5      5       5       rS\R                  " St5      \R                  " StSu5       " Sv Sw\O5      5       5       rT\R                  " Sx5      \R                  " SxSy5       " Sz S{\O5      5       5       rU\R                  " S|5       " S} S~\B5      5       rV\R                  " S5      \R                  " SS5       " S S\B5      5       5       rW " S S\B5      rX " S S\X5      rY " S S\X5      rZ " S S\X5      r[ " S S\B5      r\g)    )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                  n    \ rS rSr% Sr\R                  S
S j5       r\" 5       r	S\
S'   SS jrSS jrSrg	)MigrateOperation>   zbase 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`

c                    0 $ )zqA dictionary that may be used to store arbitrary information
along with this :class:`.MigrateOperation` object.

 selfs    ^/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/alembic/operations/ops.pyinfoMigrateOperation.infoM   s	     	    zFrozenSet[Rewriter]
_mutationsc                    [         eNNotImplementedErrorr>   s    r@   reverseMigrateOperation.reverseW       !!rC   c                    [         erF   rG   r>   s    r@   to_diff_tupleMigrateOperation.to_diff_tupleZ   rK   rC   r=   N)returnzDict[Any, Any])rO   r:   rO   zTuple[Any, ...])__name__
__module____qualname____firstlineno____doc__r   memoized_propertyrA   	frozensetrD   __annotations__rI   rM   __static_attributes__r=   rC   r@   r:   r:   >   s:     
  '0kJ#1""rC   r:   c                      \ rS rSrSr\R                  " 5       r\SS j5       r	\
    SS j5       r\
SS j5       r\ S   SS jj5       rSS jrSS	 jrS
rg)r8   ^   z&Represent an add constraint operation.c                    [        5       erF   rG   r>   s    r@   constraint_typeAddConstraintOp.constraint_typec   s    !##rC   c                   ^ ^ SU U4S jjnU$ )Nc                ^   > TR                   R                  T5      " U R                  5        U $ rF   )add_constraint_opsdispatch_forfrom_constraint)klassclstype_s    r@   go3AddConstraintOp.register_add_constraint.<locals>.gok   s'    ""//6u7L7LMLrC   )rd   	Type[_AC]rO   ri   r=   )re   rf   rg   s   `` r@   register_add_constraint'AddConstraintOp.register_add_constraintg   s    	 	 	rC   c                X    U R                   R                  UR                  5      " U5      $ rF   )ra   dispatch__visit_name__)re   
constraints     r@   rc   AddConstraintOp.from_constraintq   s)    %%..z/H/HI
 	
rC   Nc                    g rF   r=   )r?   migration_contexts     r@   to_constraintAddConstraintOp.to_constraintw   s     	rC   c                H    [         R                  U R                  5       5      $ rF   )DropConstraintOprc   rs   r>   s    r@   rI   AddConstraintOp.reverse}   s    //0B0B0DEErC   c                &    SU R                  5       4$ )Nadd_constraintrs   r>   s    r@   rM   AddConstraintOp.to_diff_tuple   s     $"4"4"677rC   r=   )rO   str)rf   r|   rO   z Callable[[Type[_AC]], Type[_AC]])ro   r'   rO   r8   rF   )rr   Optional[MigrationContext]rO   r'   )rO   rv   )rO   zTuple[str, Constraint])rQ   rR   rS   rT   rU   r   
Dispatcherra   propertyr]   classmethodrj   rc   r   rs   rI   rM   rY   r=   rC   r@   r8   r8   ^   s    0*$ $ 	)  
 

 >B!;	 
F8rC   drop_constraintbatch_drop_constraintc                      \ rS rSrSr SSSS.           SS jjjrSS jr  SS jr\SS j5       r	SS	 jr
\ SSS
.           SS jjj5       r\ S       SS jj5       rSrg)rv      z&Represent a drop constraint operation.Nschema_reversec               @    Xl         X l        X0l        X@l        XPl        g rF   )constraint_name
table_namer]   r   r   )r?   r   r   rf   r   r   s         r@   __init__DropConstraintOp.__init__   s      /$$ rC   c                H    [         R                  U R                  5       5      $ rF   )r8   rc   rs   r>   s    r@   rI   DropConstraintOp.reverse   s    ..t/A/A/CDDrC   c                j    U R                   S:X  a  SU R                  5       4$ SU R                  5       4$ )N
foreignkey	remove_fkremove_constraint)r]   rs   r>   s    r@   rM   DropConstraintOp.to_diff_tuple   s:     </!3!3!566'););)=>>rC   c           	        SSSSSSS.n[         R                  " U5      nU " [         R                  " UR                  5      UR                  UR                  UR                  UR                  5      [        R                  U5      S9$ )Nuniquer   primarycheck)unique_constraintforeign_key_constraintprimary_key_constraintcheck_constraintcolumn_check_constraint table_or_column_check_constraint)r   rf   r   )	r   _table_for_constraintconstraint_name_or_nonenamer   getrn   r8   rc   )re   ro   typesconstraint_tables       r@   rc    DropConstraintOp.from_constraint   s     "*&2&/ ''.07
 '<<ZH//
@!!#**))J556$44Z@
 	
rC   c                    U R                   be  U R                   R                  5       nU R                  Ul        [        R
                  " U5      nU R                  Ul        U R                  Ul        U$ [        S5      e)NzAconstraint cannot be produced; original constraint is not present)	r   rs   r   r   r   r   r   r   
ValueError)r?   ro   r   s      r@   rs   DropConstraintOp.to_constraint   sn    ==$446J"22JO*@@L$(OO!&*kk#5 rC   r   c               2    U " X#XES9nUR                  U5      $ )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`.

rf   r   invoke)re   
operationsr   r   rf   r   ops          r@   r    DropConstraintOp.drop_constraint   s!    . EI  $$rC   c                    U " UUR                   R                  UUR                   R                  S9nUR                  U5      $ )zIssue 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   implr   r   r   )re   r   r   rf   r   s        r@   r   &DropConstraintOp.batch_drop_constraint   sA    $ OO&&??))	
   $$rC   )r   r   r]   r   r   rF   )r   ,Optional[sqla_compat._ConstraintNameDefined]r   r|   rf   Optional[str]r   r   r   zOptional[AddConstraintOp]rO   None)rO   r8   )rO   zTuple[str, SchemaItem])ro   r'   rO   rv   )rO   r'   )r   r   r   r|   r   r|   rf   r   r   r   rO   r   )r   r   r   r|   rf   r   rO   r   )rQ   rR   rS   rT   rU   r   rI   rM   r   rc   rs   r   r   rY   r=   rC   r@   rv   rv      s     1  $	! !%.2!E! ! 	! ! ,! 
!E?	? 
 
&   $% !%%% % 	%
 % % 
% %2 
  $	%#% % 	%
 
% %rC   rv   create_primary_keybatch_create_primary_keyr   c                      \ rS rSrSrSrSS.           SS jjr\SS j5       r S   SS jjr	\SS.           SS	 jj5       r
\        SS
 j5       rSrg)CreatePrimaryKeyOp   z)Represent a create primary key operation.
primarykeyNr   c               @    Xl         X l        X0l        X@l        XPl        g rF   r   r   columnsr   kwr?   r   r   r   r   r   s         r@   r   CreatePrimaryKeyOp.__init__        /$rC   c                   [         R                  " U5      n[        SU5      nU " [         R                  " UR                  5      UR                  UR
                  R                  5       4SUR                  0UR                  D6$ )Nr,   r   )	r   r   r   r   r   r   keysr   dialect_kwargs)re   ro   r   pk_constraints       r@   rc   "CreatePrimaryKeyOp.from_constraint  s|    &<<ZH3Z@//0B0BC!!!!&&(
 $**	

 **
 	
rC   c                    [         R                  " U5      nUR                  " U R                  U R                  U R
                  4SU R                  0U R                  D6$ Nr   )r   SchemaObjectsr   r   r   r   r   r   r?   rr   
schema_objs      r@   rs    CreatePrimaryKeyOp.to_constraint   s[     ,,->?
00  OOLL
 ;;	

 gg
 	
rC   c               2    U " X#XES9nUR                  U5      $ )aJ  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   )re   r   r   r   r   r   r   s          r@   r   %CreatePrimaryKeyOp.create_primary_key-  s"    X gE  $$rC   c                    U " UUR                   R                  UUR                   R                  S9nUR                  U5      $ )zIssue 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   )re   r   r   r   r   s        r@   r   +CreatePrimaryKeyOp.batch_create_primary_key\  sA    $ OO&&??))	
   $$rC   r   r   r   r   r   r   r   r   r|   r   Sequence[str]r   r   r   r   rO   r   )ro   r'   rO   r   rF   )rr   r}   rO   r,   )r   r   r   r   r   r|   r   	List[str]r   r   rO   r   )r   r   r   r   r   r   rO   r   )rQ   rR   rS   rT   rU   r]   r   r   rc   rs   r   r   rY   r=   rC   r@   r   r      s    4"O !%E  	   
 	
 	
 ?C
!;
	
  !%,%,% ',% 	,%
 ,% ,% 
,% ,%\ %#% '% 	%
 
% %rC   r   create_unique_constraintbatch_create_unique_constraintr   c                      \ rS rSrSrSrSS.           SS jjr\    SS j5       r S   SS jjr	\SS.             SS	 jj5       r
\          SS
 j5       rSrg)CreateUniqueConstraintOpiw  z/Represent a create unique constraint operation.r   Nr   c               @    Xl         X l        X0l        X@l        XPl        g rF   r   r   s         r@   r   !CreateUniqueConstraintOp.__init__  r   rC   c                   [         R                  " U5      n[        SU5      n0 nUR                  (       a  UR                  US'   UR                  (       a  UR                  US'   UR                  UR                  5        U " [         R                  " UR                  5      UR                  UR                   Vs/ s H  oUR                  PM     sn4SUR                  0UD6$ s  snf )Nr/   
deferrable	initiallyr   )r   r   r   r   r   updater   r   r   r   r   )re   ro   r   uq_constraintr   cs         r@   rc   (CreateUniqueConstraintOp.from_constraint  s     '<<ZH/<##,77B|""+55B{O
		-..///0B0BC!!*2232VV23
 $**	

 
 	
 4s   :C#c                    [         R                  " U5      nUR                  " U R                  U R                  U R
                  4SU R                  0U R                  D6$ r   )r   r   r   r   r   r   r   r   r   s      r@   rs   &CreateUniqueConstraintOp.to_constraint  s[     ,,->?
++  OOLL
 ;;	

 gg
 	
rC   c               <    U " X#U4SU0UD6nUR                  U5      $ )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   )re   r   r   r   r   r   r   r   s           r@   r   1CreateUniqueConstraintOp.create_unique_constraint  s,    b gKfKK  $$rC   c                    UR                   R                  US'   U " X!R                   R                  U40 UD6nUR                  U5      $ )zIssue 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   r   r   )re   r   r   r   r   r   s         r@   r   7CreateUniqueConstraintOp.batch_create_unique_constraint  sC    & "--8//"<"<gLL  $$rC   r   r   )ro   r'   rO   r   rF   )rr   r}   rO   r/   )r   r   r   r   r   r|   r   r   r   r   r   r   rO   r   )
r   r   r   r|   r   r   r   r   rO   r   )rQ   rR   rS   rT   rU   r]   r   r   rc   rs   r   r   rY   r=   rC   r@   r   r   w  s1    :O !%E  	   
 
#
	!
 
, ?C

!;

	

  !%1%1% '1% 	1%
 1% 1% 1% 
1% 1%f %#% % 	%
 % 
% %rC   r   create_foreign_keybatch_create_foreign_keyr   c            	      0   \ rS rSrSrSr              SS jrSS jr\SS j5       r	 S   SS jjr
\SSSSSSSS	.                             SS
 jj5       r\SSSSSSS.                         SS jj5       rSrg)CreateForeignKeyOpi  z4Represent a create foreign key constraint operation.r   c                L    Xl         X l        X0l        X@l        XPl        X`l        g rF   )r   source_tablereferent_table
local_colsremote_colsr   )r?   r   r   r   r   r   r   s          r@   r   CreateForeignKeyOp.__init__  s&      /(,$&rC   c                &    SU R                  5       4$ )Nadd_fkrz   r>   s    r@   rM    CreateForeignKeyOp.to_diff_tuple  s    $,,.//rC   c           
     |   [        SU5      n0 nUR                  (       a  UR                  US'   UR                  (       a  UR                  US'   UR                  (       a  UR                  US'   UR                  (       a  UR                  US'   UR
                  (       a  UR
                  US'   UR                  (       a  UR                  US'   [        R                  " U5      u
  nnnnnn	n
nnnXCS'   XsS	'   UR                  UR                  5        U " [        R                  " UR                  5      UUUU	40 UD6$ )
Nr(   onupdateondeleter   r   	use_altermatchsource_schemareferent_schema)r   r   r   r   r   r   r   r   _fk_specr   r   r   r   )re   ro   fk_constraintr   r   r   source_columnstarget_schematarget_tabletarget_columnsr   r   r   r   s                 r@   rc   "CreateForeignKeyOp.from_constraint  s4   3Z@!!*33BzN!!*33BzN""+55B{O##,77B|""+55B{O'--BwK   /	
 ,? -
		-..///0B0BC
 
 	
rC   Nc                    [         R                  " U5      nUR                  " U R                  U R                  U R
                  U R                  U R                  40 U R                  D6$ rF   )	r   r   r   r   r   r   r   r   r   r   s      r@   rs    CreateForeignKeyOp.to_constraintE  sa     ,,->?
00  OO
 gg
 	
rC   )r   r   r   r   r   r   r   c               N    U " UUUUU4UUU	UUU
US.UD6nUR                  U5      $ )af  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   )re   r   r   r   r   r   r   r   r   r   r   r   r   r   
dialect_kwr   s                   r@   r   %CreateForeignKeyOp.create_foreign_keyR  sW    J 
 !'+
 
   $$rC   )r   r   r   r   r   r   c                   U " UUR                   R                  UUU4UUU	UR                   R                  UU
US.UD6nUR                  U5      $ )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   )re   r   r   r   r   r   r   r   r   r   r   r   r	  r   s                 r@   r   +CreateForeignKeyOp.batch_create_foreign_key  sk    L OO&&
 !$//00+
 
   $$rC   )r   r   r   r   r   r   )r   r   r   r|   r   r|   r   r   r   r   r   r   rO   r   )rO   z Tuple[str, ForeignKeyConstraint])ro   r'   rO   r   rF   )rr   r}   rO   r(   )r   r   r   r   r   r|   r   r|   r   r   r   r   r   r   r   r   r   Optional[bool]r   r   r   r   r   r   r   r   r	  r   rO   r   )r   r   r   r   r   r|   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r	  r   rO   r   )rQ   rR   rS   rT   rU   r]   r   rM   r   rc   rs   r   r   rY   r=   rC   r@   r   r     s    ?"OE  	
    
 0 '
 '
T ?C
!;
	
  #'"&%)#'#'+)-S%S% 'S% 	S%
 S% S% S%  S%  S% #S% !S% S% %S% 'S%  !S%" 
#S% S%j  *."&"&%)#'#4%#4% '4% 	4%
 4% 4% '4%  4%  4% #4% !4% 4% 4% 
4% 4%rC   r   create_check_constraintbatch_create_check_constraintr   r   r   c                      \ rS rSrSrSrSS.           SS jjr\    SS j5       r S   SS jjr	\SS.             SS	 jj5       r
\          SS
 j5       rSrg)CreateCheckConstraintOpi  z.Represent a create check constraint operation.r   Nr   c               @    Xl         X l        X0l        X@l        XPl        g rF   )r   r   	conditionr   r   )r?   r   r   r  r   r   s         r@   r    CreateCheckConstraintOp.__init__  s      /$"rC   c                    [         R                  " U5      n[        SU5      nU " [         R                  " UR                  5      UR                  [        SUR
                  5      4SUR                  0UR                  D6$ )Nr$   zColumnElement[Any]r   )r   r   r   r   r   sqltextr   r   )re   ro   r   ck_constraints       r@   rc   'CreateCheckConstraintOp.from_constraint  s}     '<<ZH.
;//0B0BC!!%}'<'<=
 $**	

 **
 	
rC   c                    [         R                  " U5      nUR                  " U R                  U R                  U R
                  4SU R                  0U R                  D6$ r   )r   r   r   r   r   r  r   r   r   s      r@   rs   %CreateCheckConstraintOp.to_constraint
  s[     ,,->?
**  OONN
 ;;	

 gg
 	
rC   c               <    U " X#U4SU0UD6nUR                  U5      $ )a  Issue 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   )re   r   r   r   r  r   r   r   s           r@   r  /CreateCheckConstraintOp.create_check_constraint  s,    f iMM"M  $$rC   c                    U " UUR                   R                  U4SUR                   R                  0UD6nUR                  U5      $ )zIssue 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   )re   r   r   r  r   r   s         r@   r  5CreateCheckConstraintOp.batch_create_check_constraintL  sR    & OO&&
 ??))	

 
   $$rC   )r  r   r   r   r   )r   r   r   r|   r  z*Union[str, TextClause, ColumnElement[Any]]r   r   r   r   rO   r   )ro   r'   rO   r  rF   )rr   r}   rO   r$   )r   r   r   r   r   r|   r  +Union[str, ColumnElement[bool], TextClause]r   r   r   r   rO   r   )
r   r   r   r|   r  r  r   r   rO   r   )rQ   rR   rS   rT   rU   r]   r   r   rc   rs   r  r  rY   r=   rC   r@   r  r    s1    9O !%E  >	   
 
#
	 
 
 ?C

!;

	

  !%3%3% '3% 	3%
 ?3% 3% 3% 
3% 3%j %#% % ?	%
 % 
% %rC   r  create_indexbatch_create_indexc                      \ rS rSrSrSSSS.               SS jjrSS jrSS jr\SS	 j5       r	 S   SS
 jjr
\SSSS.                 SS jj5       r\          SS j5       rSrg)CreateIndexOpii  z#Represent a create index operation.NFr   r   if_not_existsc               X    Xl         X l        X0l        X@l        XPl        X`l        Xpl        g rF   )
index_namer   r   r   r   r%  r   )r?   r'  r   r   r   r   r%  r   s           r@   r   CreateIndexOp.__init__n  s(     %$*rC   c                H    [         R                  U R                  5       5      $ rF   )DropIndexOp
from_indexto_indexr>   s    r@   rI   CreateIndexOp.reverse  s    %%dmmo66rC   c                &    SU R                  5       4$ )N	add_indexr,  r>   s    r@   rM   CreateIndexOp.to_diff_tuple      T]]_--rC   c                    UR                   c   eU " UR                  UR                   R                  UR                  4UR                   R                  UR                  S.UR
                  D6$ N)r   r   )tabler   expressionsr   r   kwargsre   indexs     r@   r+  CreateIndexOp.from_index  se    {{&&&JJKK
 ;;%%<<
 ll
 	
rC   c                    [         R                  " U5      nUR                  " U R                  U R                  U R
                  4U R                  U R                  S.U R                  D6nU$ r4  )	r   r   r9  r'  r   r   r   r   r   )r?   rr   r   idxs       r@   r,  CreateIndexOp.to_index  sd     ,,->?
OOOOLL
 ;;;;
 gg
 
rC   c               B    U " UUU4UUUS.UD6n	UR                  U	5      $ )az  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.

r$  r   )
re   r   r'  r   r   r   r   r%  r   r   s
             r@   r   CreateIndexOp.create_index  sE    x 
 '
 
   $$rC   c                    U " UUR                   R                  U4SUR                   R                  0UD6nUR                  U5      $ )zIssue a "create index" instruction using the
current batch migration context.

.. seealso::

    :meth:`.Operations.create_index`

r   r   )re   r   r'  r   r   r   s         r@   r!   CreateIndexOp.batch_create_index  sR    " OO&&
 ??))	

 
   $$rC   )r   r%  r'  r   r   r   r   )r'  r   r   r|   r   z4Sequence[Union[str, TextClause, ColumnElement[Any]]]r   r   r   boolr%  r  r   r   rO   r   )rO   r*  rO   zTuple[str, Index])r9  r*   rO   r#  rF   rr   r}   rO   r*   )r   r   r'  r   r   r|   r   z/Sequence[Union[str, TextClause, Function[Any]]]r   r   r   rB  r%  r  r   r   rO   r   )
r   r   r'  r|   r   r   r   r   rO   r   )rQ   rR   rS   rT   rU   r   rI   rM   r   r+  r,  r   r!  rY   r=   rC   r@   r#  r#  i  sg    . !%(,!  F	   &  
&7. 	
 	
 ?C!;	  !%(,D%D% "D% 	D%
 AD% D% D% &D% D% 
D% D%L %#% % 	%
 % 
% %rC   r#  
drop_indexbatch_drop_indexc                      \ rS rSrSr SSSSS.             SS jjjrSS jrSS jr\SS j5       r	 S   SS	 jjr
\ SSSS
.             SS jjj5       r\        SS j5       rSrg)r*  i  z!Represent a drop index operation.N)r   	if_existsr   c               L    Xl         X l        X0l        X@l        XPl        X`l        g rF   )r'  r   r   rH  r   r   )r?   r'  r   r   rH  r   r   s          r@   r   DropIndexOp.__init__	  s"     %$" rC   c                &    SU R                  5       4$ )Nremove_indexr0  r>   s    r@   rM   DropIndexOp.to_diff_tuple      00rC   c                H    [         R                  U R                  5       5      $ rF   )r#  r+  r,  r>   s    r@   rI   DropIndexOp.reverse      ''88rC   c                    UR                   c   eU " UR                  4UR                   R                  UR                   R                  [        R	                  U5      UR
                  S.UR                  D6$ )N)r   r   r   r   )r5  r   r   r#  r+  r   r7  r8  s     r@   r+  DropIndexOp.from_index   sh    {{&&&JJ
{{'';;%%"--e4<<
 ll
 	
rC   c                    [         R                  " U5      nUR                  " U R                  U R                  U R
                  (       a  U R
                  R                  OS/4SU R                  0U R                  D6$ )Nxr   )	r   r   r9  r'  r   r   r   r   r   r   s      r@   r,  DropIndexOp.to_index,  sk     ,,->?
 OOOO%)]]DMM!!
 ;;	

 gg
 	
rC   r   rH  c               >    U " U4UUUS.UD6nUR                  U5      $ )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.

)r   r   rH  r   )re   r   r'  r   r   rH  r   r   s           r@   rE  DropIndexOp.drop_index;  s=    L 
!	

 
   $$rC   c                    U " U4UR                   R                  UR                   R                  S.UD6nUR                  U5      $ )zIssue a "drop index" instruction using the
current batch migration context.

.. seealso::

    :meth:`.Operations.drop_index`

r   r   r   )re   r   r'  r   r   s        r@   rF  DropIndexOp.batch_drop_indexj  sM     
!11??))
 	
   $$rC   )r   rH  r'  r   r   r   rF   )r'  zUnion[quoted_name, str, conv]r   r   r   r   rH  r  r   zOptional[CreateIndexOp]r   r   rO   r   rC  )rO   r#  )r9  r*   rO   r*  rD  )r   r   r'  r|   r   r   r   r   rH  r  r   r   rO   r   )r   r   r'  r|   r   r   rO   r   )rQ   rR   rS   rT   rU   r   rM   rI   r   r+  r,  rE  rF  rY   r=   rC   r@   r*  r*    s=    ,
 %)
 !%$(,01 "
  " *  
"19 	
 	
 ?C
!;
	
 
 %)	,% !%$(,%,% ,% "	,% ,% ",% ,% 
,% ,%\ %(%69%AD%	% %rC   r*  create_tablec                      \ rS rSrSrSSSSS.               SS jjrSS jrSS jr\SS	.     SS
 jj5       r	 S   SS jjr
\SS.           SS jj5       rSrg)CreateTableOpi  z#Represent a create table operation.NF)r   r%  _namespace_metadata_constraints_includedc                   Xl         X l        X0l        X@l        UR	                  S0 5      U l        UR	                  SS 5      U l        UR	                  SS 5      U l        Xpl        XPl	        X`l
        g )NrA   commentprefixes)r   r   r   r%  poprA   rc  rd  r   r`  ra  )r?   r   r   r   r%  r`  ra  r   s           r@   r   CreateTableOp.__init__  s`     %*FF62&	vvi.z40#6 %:"rC   c                Z    [         R                  U R                  5       U R                  S9$ )Nr`  )DropTableOp
from_tableto_tabler`  r>   s    r@   rI   CreateTableOp.reverse  s+    %%MMO1I1I & 
 	
rC   c                &    SU R                  5       4$ )N	add_tablerk  r>   s    r@   rM   CreateTableOp.to_diff_tuple  r2  rC   rh  c               0   Uc  UR                   nU " UR                  [        UR                  5      [        UR                  5      -   4UR
                  USUR                  [        UR                  5      [        UR                  5      S.UR                  D6$ )NT)r   r`  ra  rc  rA   rd  )metadatar   listr   constraintsr   rc  dictrA   	_prefixesr7  re   r5  r`  s      r@   rj  CreateTableOp.from_table  s     &"'..JJMD!2!233
 << 3 #'MMejj!%//*
 ll
 	
rC   c           	        [         R                  " U5      nUR                  " U R                  /U R                  Q7U R
                  U R                  (       a  [        U R                  5      O/ U R                  U R                  (       a  U R                  R                  5       O0 U R                  S.U R                  D6$ )N)r   rd  rc  rA   ra  )r   r   r5  r   r   r   rd  rs  rc  rA   copyra  r   r   s      r@   rk  CreateTableOp.to_table  s     ,,->?
OO	
\\	
 ;;,0MMT$--(rLL%)YY!B"&"<"<	
 gg	
 		
rC   )r%  c               :    U " X$4SU0UD6nUR                  U5      $ )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.

r%  r   )re   r   r   r%  r   r   r   s          r@   r]  CreateTableOp.create_table  s*    t HMHRH  $$rC   )
ra  r`  r   rc  r%  rA   r   rd  r   r   )r   r|   r   zSequence[SchemaItem]r   r   r%  r  r`  Optional[MetaData]ra  rB  r   r   rO   r   )rO   ri  rO   zTuple[str, Table])r5  r.   r`  r~  rO   r_  rF   rr   r}   rO   r.   )r   r   r   r|   r   r-   r%  r  r   r   rO   r.   )rQ   rR   rS   rT   rU   r   rI   rM   r   rj  rk  r]  rY   r=   rC   r@   r_  r_    s   - !%(,26&+;; &;
 ; &; 0;  $; ; 
;,

. HL

3E
	
 
2 ?C
!;
	
   )-Z%Z% Z% 	Z%
 &Z% Z% 
Z% Z%rC   r_  
drop_tablec                      \ rS rSrSrSSSSS.           SS jjrSS jrSS jr\SS.     SS	 jj5       r	 S   SS
 jjr
\SSS.           SS jj5       rSrg)ri  i)  z!Represent a drop table operation.N)r   rH  table_kwr   c                  Xl         X l        X0l        U=(       d    0 U l        U R                  R	                  SS 5      U l        U R                  R	                  SS 5      U l        U R                  R	                  SS 5      U l        XPl        g )Nrc  rA   rd  )	r   r   rH  r  re  rc  rA   rd  r   )r?   r   r   rH  r  r   s         r@   r   DropTableOp.__init__-  sk     %" B}}((D9MM%%fd3	))*d; rC   c                &    SU R                  5       4$ )Nremove_tablero  r>   s    r@   rM   DropTableOp.to_diff_tuple?  rN  rC   c                H    [         R                  U R                  5       5      $ rF   )r_  rj  rk  r>   s    r@   rI   DropTableOp.reverseB  rQ  rC   rh  c          
         U " UR                   UR                  UR                  [        UR                  5      [        UR                  5      S.UR                  E[        R                  XS9S9$ )N)rc  rA   rd  rh  )r   r  r   )
r   r   rc  ru  rA   rs  rv  r7  r_  rj  rw  s      r@   rj  DropTableOp.from_tableE  si     JJ<< ==UZZ( 1 ,,	 #-- . 
 	
rC   c           	        U R                   (       a  U R                   R                  nO/ n[        R                  " U5      nUR                  " U R
                  /UQ7U R                  U R                  (       a  U R                  R                  5       O0 U R                  (       a  [        U R                  5      O/ U R                  U R                   (       a  U R                   R                  OSS.U R                  D6nU$ )NF)rc  rA   rd  r   ra  )r   r   r   r   r5  r   rc  rA   rz  rd  rs  r   ra  r  )r?   rr   cols_and_constraintsr   ts        r@   rk  DropTableOp.to_tableW  s     ==#'==#8#8 #% ,,->?
OO
!
 LL%)YY!B,0MMT$--(r;;7;}}33%
 mm
 rC   rW  c               4    U " X#XES9nUR                  U5        g)aH  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   rH  r  Nr   )re   r   r   r   rH  r   r   s          r@   r  DropTableOp.drop_tablen  s    > iM"rC   )r   rc  rH  rA   rd  r   r  r   )r   r|   r   r   rH  r  r  z"Optional[MutableMapping[Any, Any]]r   zOptional[CreateTableOp]rO   r   r  )rO   r_  )r5  r.   r`  r~  rO   ri  rF   r  )r   r   r   r|   r   r   rH  r  r   r   rO   r   )rQ   rR   rS   rT   rU   r   rM   rI   r   rj  rk  r  rY   r=   rC   r@   ri  ri  )  s    + !%$(7;,0!! 	!
 "! 5! *! 
!$19 HL

3E
	
 
$ ?C!;	.  !%$( 
  "  
 rC   ri  c                  4    \ rS rSrSrSS.     SS jjrSrg)AlterTableOpi  z#Represent an alter table operation.Nr   c                   Xl         X l        g rF   r[  )r?   r   r   s      r@   r   AlterTableOp.__init__  s     %rC   r   r   )r   r|   r   r   rO   r   )rQ   rR   rS   rT   rU   r   rY   r=   rC   r@   r  r    s0    - !%	 	
 
 rC   r  rename_tablec                  t   ^  \ rS rSrSrSS.       SU 4S jjjr\SS.         S	S jj5       rSrU =r	$ )
RenameTableOpi  z#Represent a rename table operation.Nr   c               ,   > [         TU ]  XS9  X l        g Nr   )superr   new_table_name)r?   old_table_namer  r   	__class__s       r@   r   RenameTableOp.__init__  s     	7,rC   c               2    U " X#US9nUR                  U5      $ )a4  Emit 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   )re   r   r  r  r   r   s         r@   r  RenameTableOp.rename_table  s!    & ?  $$rC   )r  )r  r|   r  r|   r   r   rO   r   )
r   r   r  r|   r  r|   r   r   rO   r   )
rQ   rR   rS   rT   rU   r   r   r  rY   __classcell__r  s   @r@   r  r    s    - !%-- -
 - 
- -  !%%% % 	% % 
% %rC   r  create_table_commentbatch_create_table_commentc                      \ rS rSrSrSSS.         SS jjr\SSS.           SS jj5       r\SS.       SS	 jj5       rSS
 jr	 S   SS jjr
SS jrSrg)CreateTableCommentOpi  z)Represent a COMMENT ON `table` operation.Nr   existing_commentc               4    Xl         X l        X@l        X0l        g rF   )r   rc  r  r   )r?   r   rc  r   r  s        r@   r   CreateTableCommentOp.__init__  s     % 0rC   r  r   c               6    U " UUUUS9nUR                  U5      $ )a  Emit 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`

r  r   )re   r   r   rc  r  r   r   s          r@   r  )CreateTableCommentOp.create_table_comment  s-    8 -	
   $$rC   r  c                   U " UR                   R                  UUUR                   R                  S9nUR                  U5      $ )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.

r  r   )re   r   rc  r  r   s        r@   r  /CreateTableCommentOp.batch_create_table_comment  sA    ( OO&&-??))	
   $$rC   c                    U R                   c)  [        U R                  U R                  U R                  S9$ [        U R                  U R                   U R                  U R                  S9$ )2Reverses the COMMENT ON operation against a table.r  )r  DropTableCommentOpr   rc  r   r  r>   s    r@   rI   CreateTableCommentOp.reverse  s]      (%!%{{  (%%!%{{	 rC   c                    [         R                  " U5      nUR                  U R                  U R                  U R
                  S9$ )N)r   rc  )r   r   r5  r   r   rc  r   s      r@   rk  CreateTableCommentOp.to_table'  s@     ,,->?
OODKK   
 	
rC   c                <    SU R                  5       U R                  4$ )Nadd_table_comment)rk  r  r>   s    r@   rM   "CreateTableCommentOp.to_diff_tuple0  s    #T]]_d6K6KLLrC   )rc  r  r   r   )
r   r|   rc  r   r   r   r  r   rO   r   )r   r   r   r|   rc  r   r  r   r   r   rO   r   )r   r   rc  r   r  r   rO   r   )rO   z/Union[CreateTableCommentOp, DropTableCommentOp]rF   r  rP   )rQ   rR   rS   rT   rU   r   r   r  r  rI   rk  rM   rY   r=   rC   r@   r  r    s    
 4 !%*. 
  ( 
  +/ $!%!% !% 	!% (!% !% 
!% !%F  +/%#% %
 (% 
% %6" ?C
!;
	
MrC   r  drop_table_commentbatch_drop_table_commentc                      \ rS rSrSrSSS.       SS jjr\SSS.         SS jj5       r\SS.     SS	 jj5       rSS
 jr	 S   SS jjr
SS jrSrg)r  i4  z:Represent an operation to remove the comment from a table.Nr  c               (    Xl         X0l        X l        g rF   )r   r  r   )r?   r   r   r  s       r@   r   DropTableCommentOp.__init__;  s     % 0rC   r  c               2    U " X#US9nUR                  U5      $ )ad  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`

r  r   )re   r   r   r  r   r   s         r@   r  %DropTableCommentOp.drop_table_commentF  s!    0 vN  $$rC   r  c                   U " UR                   R                  UUR                   R                  S9nUR                  U5      $ )zIssue 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.

r  r   )re   r   r  r   s       r@   r  +DropTableCommentOp.batch_drop_table_commenta  s>      OO&&-??))

   $$rC   c                T    [        U R                  U R                  U R                  S9$ )r  r   )r  r   r  r   r>   s    r@   rI   DropTableCommentOp.reversex  s$    #OOT224;;
 	
rC   c                v    [         R                  " U5      nUR                  U R                  U R                  S9$ r  )r   r   r5  r   r   r   s      r@   rk  DropTableCommentOp.to_table~  s3     ,,->?
DDrC   c                &    SU R                  5       4$ )Nremove_table_commentro  r>   s    r@   rM    DropTableCommentOp.to_diff_tuple  s    &88rC   )r  r   r   )r   r|   r   r   r  r   rO   r   )
r   r   r   r|   r  r   r   r   rO   r   )r   r   r  r   rO   r   )rO   r  rF   r  rP   )rQ   rR   rS   rT   rU   r   r   r  r  rI   rk  rM   rY   r=   rC   r@   r  r  4  s    
 E !%*.		 		
 (	 
	  +/ $%% %
 (% % 
% %4 
 +/	%#% (	%
 
% %,
 ?CE!;E	E9rC   r  alter_columnbatch_alter_columnc                  p  ^  \ rS rSrSrSSSSSSSSSSS.
                           SU 4S jjjrSS jrSS jrSS	 jr\	SSSSSSSSSSS
.
                             SS jj5       r
\	SSSSSSSSSSSS.                             SS jj5       rSrU =r$ )AlterColumnOpi  z$Represent an alter column operation.NF)
r   existing_typeexisting_server_defaultexisting_nullabler  modify_nullablemodify_commentmodify_server_defaultmodify_namemodify_typec       
           > [         TU ]  XS9  X l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        Xl
        Xl        Xl        g r  )r  r   column_namer  r  r  r  r  r  r  r  r  r   )r?   r   r  r   r  r  r  r  r  r  r  r  r  r   r  s                 r@   r   AlterColumnOp.__init__  sV    " 	3&*'>$!2 0.,%:"&&rC   c           
     0   / nU R                   U R                  U R                  pCnU R                  bN  UR	                  SUUUU R
                  U R                  U R                  S.U R                  U R                  45        U R                  bN  UR	                  SUUUU R                  U R                  U R                  S.U R
                  U R                  45        U R                  SLaN  UR	                  SUUUU R
                  U R                  U R                  S.U R                  U R                  45        U R                  SLaN  UR	                  SUUUU R
                  U R                  U R                  S	.U R                  U R                  45        U$ )
Nr  )r  r  r  r  )r  r  r  Fmodify_default)r  r  r  r  )r  r  r  )r   r   r  r  appendr  r  r  r  r  r  r  )r?   col_diffr   tnamecnames        r@   rM   AlterColumnOp.to_diff_tuple  s   #{{DOOT=M=Mu'OO!-1-C-C 88,0,A,A &&$$$ +OO%)-);); 88,0,A,A **(($ %%U2OO$-1-C-C)-););,0,A,A
 00..  e+OO$-1-C-C)-);); 88	 ))''$ rC   c                   U R                   S L=(       d8    U R                  SL=(       d#    U R                  S L=(       d    U R                  SLnU(       a  gU R                   H  nUR                  S5      (       d  M    g   g)NFTmodify_)r  r  r  r  r   
startswith)r?   hc1r   s      r@   has_changesAlterColumnOp.has_changes  s}      , 0))60t+0 ""%/	 	 ''B}}Y''  rC   c                   U R                   R                  5       nU R                  US'   U R                  US'   U R                  US'   U R
                  US'   U R                  b  U R                  US'   U R                  b  U R                  US'   U R                  SLa  U R                  US'   U R                  SLa  U R                  US	'   U Vs/ s H  n[        R                  " S
U5      PM     sn Vs1 s H  nU(       d  M  UR                  S5      iM     nnU H+  nSU-  U;   d  M  USU-     nUSU-     USU-  '   XQSU-  '   M-     U R                  " U R                  U R                  4SU R                   0UD6$ s  snf s  snf )Nr  r  r  r  r  r  Fr  r  z^(?:existing_|modify_)(.+)$r   z	modify_%szexisting_%sr   )r   rz  r  r  r  r  r  r  r  r  rer   groupr  r   r  r   )r?   r   kmall_keysswaps         r@   rI   AlterColumnOp.reverse  s   WW\\^"00?"&"8"8(,(D(D$%!%!6!6' $ 0 0B}+$($8$8B !%%U2*.*D*DB&'e+#'#6#6B 
 LNN2abhh=qA2N
N AGGAJN 	 
 AQ"$-!+,(*;?(;=1$%&*;?#	  ~~OOT--
6:kk
EG
 	
 O
s   !F 5FF)
nullablerc  server_defaultnew_column_namerf   r  r  r  r  r   c       
        N    U " UU4UU	U
UUUUUUUS.
UD6nUR                  U5      $ )a  Issue 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  r  r  r  r  r  r  r   )re   r   r   r  r  rc  r  r  rf   r  r  r  r  r   r   alts                   r@   r  AlterColumnOp.alter_column+  sW    T 
 '$;/-'"0$"
 
    %%rC   )r  rc  r  r  rf   r  r  r  r  insert_beforeinsert_afterc                   U " UR                   R                  U4UR                   R                  UU	U
UUUUUUUUS.UD6nUR                  U5      $ )a  Issue 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  r  r  r  r  r  r  r  r  r   )re   r   r  r  rc  r  r  rf   r  r  r  r  r  r  r   r  s                   r@   r   AlterColumnOp.batch_alter_column  sq    Z OO&&
 ??))'$;/-'"0$"'%
 
$   %%rC   )r  r  r  r  r  r   r  r  r  r  r  )r   r|   r  r|   r   r   r  Optional[Any]r  r   r  r  r  r   r  r  r  $Optional[Union[str, Literal[False]]]r  r   r  r   r  r  r   r   rO   r   rO   r   rO   rB  )rO   r  )r   r   r   r|   r  r|   r  r  rc  r  r  r   r  r   rf   7Optional[Union[TypeEngine[Any], Type[TypeEngine[Any]]]]r  r  r  .Optional[Union[str, bool, Identity, Computed]]r  r  r  r   r   r   r   r   rO   r   )r   r   r  r|   r  r  rc  r  r  r   r  r   rf   r  r  r  r  r   r  r  r  r   r  r   r  r   r   r   rO   r   )rQ   rR   rS   rT   rU   r   rM   r  rI   r   r  r  rY   r  r  s   @r@   r  r    s}    / !%'+',,0*.*.?D%*%)%) 
  % "% * ( ( =  # # #   
! <N`
@  $(8=#)-IM  ,0*. $'y&y& y& 	y& !y& 6y& y& 'y& Gy&
y&"
y&" *#y&$ (%y&& 'y&( )y&* 
+y& y&v  $(8=#)-IM  ,0*.'+&*'>&#>& >&
 !>& 6>& >& '>& G>&
>&"
>&  *!>&" (#>&$ %%>&& $'>&( )>&* 
+>& >&rC   r  
add_columnbatch_add_columnc                    ^  \ rS rSrSrSS.         SU 4S jjjrSS jr  SS jrSS jr\	SS	 j5       r
\	        SS
 j5       r\	SS.         SS jj5       r\	SSS.         SS jj5       rSrU =r$ )AddColumnOpi  z"Represent an add column operation.Nr   c               8   > [         TU ]  XS9  X l        X@l        g r  )r  r   columnr   )r?   r   r  r   r   r  s        r@   r   AddColumnOp.__init__  s     	3rC   c                l    [         R                  U R                  U R                  U R                  5      $ rF   )DropColumnOpfrom_column_and_tablenamer   r   r  r>   s    r@   rI   AddColumnOp.reverse  s(    55KK$++
 	
rC   c                J    SU R                   U R                  U R                  4$ )Nr  )r   r   r  r>   s    r@   rM   AddColumnOp.to_diff_tuple  s     dkk4??DKKHHrC   c                    U R                   $ rF   )r  r>   s    r@   	to_columnAddColumnOp.to_column  s    {{rC   c                `    U " UR                   R                  XR                   R                  S9$ r  )r5  r   r   )re   cols     r@   from_columnAddColumnOp.from_column  s!    399>>3yy/?/?@@rC   c                    U " X#US9$ r  r=   re   r   r  r  s       r@   r
  %AddColumnOp.from_column_and_tablename  s     5f--rC   c               2    U " X#US9nUR                  U5      $ )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   )re   r   r   r  r   r   s         r@   r  AddColumnOp.add_column  s"    n F3  $$rC   )r  r  c                   0 nU(       a  X5S'   U(       a  XES'   U " UR                   R                  U4SUR                   R                  0UD6nUR                  U5      $ )zIssue an "add column" instruction using the current
batch migration context.

.. seealso::

    :meth:`.Operations.add_column`

r  r  r   r   )re   r   r  r  r  r   r   s          r@   r  AddColumnOp.batch_add_columnn  sj    $ "/!-~OO&&
 ??))
 	
   $$rC   )r  r   )
r   r|   r  Column[Any]r   r   r   r   rO   r   )rO   r	  rO   z+Tuple[str, Optional[str], str, Column[Any]])rO   r  )r  r  rO   r  )r   r   r  r|   r  r  rO   r  )
r   r   r   r|   r  r  r   r   rO   r   )
r   r   r  r  r  r   r  r   rO   r   )rQ   rR   rS   rT   rU   r   rI   rM   r  r   r  r
  r  r  rY   r  r  s   @r@   r  r    sM    - !%

 

 
 
 

 


I	4I
 A A .. . 	.
 
. .  !%W%W% W% 	W% W% 
W% W%r  (,&*%#% %
 %% $% 
% %rC   r  drop_columnbatch_drop_columnc                     ^  \ rS rSrSrSSS.           SU 4S jjjr  SS jrSS jr\        SS j5       r	 S   SS	 jjr
\SS
.           SS jj5       r\        SS j5       rSrU =r$ )r	  i  z"Represent a drop column operation.Nr   c               D   > [         TU ]  XS9  X l        XPl        X@l        g r  )r  r   r  r   r   )r?   r   r  r   r   r   r  s         r@   r   DropColumnOp.__init__  s%     	3& rC   c                R    SU R                   U R                  U R                  5       4$ )Nremove_column)r   r   r  r>   s    r@   rM   DropColumnOp.to_diff_tuple  s)     KKOONN	
 	
rC   c                    U R                   c  [        S5      e[        R                  U R                  U R
                  U R                   R                  5      $ )Nz;operation is not reversible; original column is not present)r   r   r  r
  r   r   r  r>   s    r@   rI   DropColumnOp.reverse  sL    == 1 
 44KK$--*>*>
 	
rC   c           
     P    U " UUR                   U[        R                  XU5      S9$ )Nr   )r   r  r
  r  s       r@   r
  &DropColumnOp.from_column_and_tablename  s.     HH ::6#N	
 	
rC   c                    U R                   b  U R                   R                  $ [        R                  " U5      nUR                  U R                  [
        5      $ rF   )r   r  r   r   r  r   r   s      r@   r  DropColumnOp.to_column  sH     ==$==''',,->?
  !1!18<<rC   r   c               :    U " X#4SU0UD6nUR                  U5      $ )a  Issue 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   )re   r   r   r  r   r   r   s          r@   r  DropColumnOp.drop_column  s*    ^ >>2>  $$rC   c                    U " UR                   R                  U4SUR                   R                  0UD6nUR                  U5      $ )zIssue a "drop column" instruction using the current
batch migration context.

.. seealso::

    :meth:`.Operations.drop_column`

r   r   )re   r   r  r   r   s        r@   r  DropColumnOp.batch_drop_column  sO     OO&&
 ??))
 	
   $$rC   )r   r  r   )r   r|   r  r|   r   r   r   zOptional[AddColumnOp]r   r   rO   r   r  )rO   r  )r   r   r  r|   r  r  rO   r	  rF   )rr   r}   rO   r  )r   r   r   r|   r  r|   r   r   r   r   rO   r   )r   r   r  r|   r   r   rO   r   )rQ   rR   rS   rT   rU   r   rM   rI   r   r
  r  r  r  rY   r  r  s   @r@   r	  r	    sC    - !%*.!! !
 ! (! ! 
! !
	4
	
 

 
 	

 

 
 ?C=!;=	=  !%/%/% /% 	/% /% /% 
/% /%b %(%7:%BE%	% %rC   r	  bulk_insertc                  f    \ rS rSrSrSS.       S	S jjr\SS.         S
S jj5       rSrg)BulkInsertOpi	  z"Represent a bulk insert operation.Tmultiinsertc               (    Xl         X l        X0l        g rF   )r5  rowsr4  )r?   r5  r6  r4  s       r@   r   BulkInsertOp.__init__	  s     
	&rC   c               4    U " X#US9nUR                  U5        g)a  Issue 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.

r3  Nr   )re   r   r5  r6  r4  r   s         r@   r0  BulkInsertOp.bulk_insert#	  s    R +6"rC   )r4  r6  r5  N)r5  Union[Table, TableClause]r6  List[Dict[str, Any]]r4  rB  rO   r   )
r   r   r5  r:  r6  r;  r4  rB  rO   r   )	rQ   rR   rS   rT   rU   r   r   r0  rY   r=   rC   r@   r2  r2  	  s    , !	'(	' #	'
 	' 
	'  !ii )i #	i i 
i irC   r2  executebatch_executec                      \ rS rSrSrSS.     S
S jjr\SS.       SS jj5       r\SS.       SS jj5       rSS jr	S	r
g)ExecuteSQLOpi	  z#Represent an execute SQL operation.Nexecution_optionsc                   Xl         X l        g rF   )r  rA  )r?   r  rA  s      r@   r   ExecuteSQLOp.__init__	  s     !2rC   c               0    U " X#S9nUR                  U5      $ )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   )re   r   r  rA  r   s        r@   r<  ExecuteSQLOp.execute	  s     p >  $$rC   c               "    U R                  XUS9$ )zkExecute the given SQL using the current migration context.

.. seealso::

    :meth:`.Operations.execute`

r@  )r<  )re   r   r  rA  s       r@   r=  ExecuteSQLOp.batch_execute	  s      {{3D  
 	
rC   c                    SU R                   4$ )Nr<  )r  r>   s    r@   rM   ExecuteSQLOp.to_diff_tuple
  s    4<<((rC   )rA  r  )r  Union[Executable, str]rA  Optional[dict[str, Any]]rO   r   )r   r   r  rJ  rA  rK  rO   r   )rO   z"Tuple[str, Union[Executable, str]])rQ   rR   rS   rT   rU   r   r   r<  r=  rM   rY   r=   rC   r@   r?  r?  	  s     . 7;	3'3 4	3
 
3  7;X%X% (X%
 4X% 
X% X%t  7;

 (

 4
 

 
$)rC   r?  c                  V    \ rS rSrSrS	S
S jjrSS jrSS jr\    SS j5       r	Sr
g)OpContaineri
  z-Represent a sequence of operations operation.c                $    [        U5      U l        g rF   )rs  ops)r?   rO  s     r@   r   OpContainer.__init__
  s    9rC   c                $    U R                   (       + $ rF   rO  r>   s    r@   is_emptyOpContainer.is_empty
  s    88|rC   c                >    [        [        R                  U 5      5      $ rF   )rs  rM  _ops_as_diffsr>   s    r@   as_diffsOpContainer.as_diffs
  s    K--d344rC   c              #     #    UR                    HK  n[        US5      (       a%  U R                  [        SU5      5       S h  vN   M9  UR	                  5       v   MM     g  N7f)NrO  rM  )rO  hasattrrV  r   rM   )re   
migrationsr   s      r@   rV  OpContainer._ops_as_diffs
  sO      ..Br5!!,,T--DEEE&&((	 !Es   ?A!AA!rR  N)r=   )rO  Sequence[MigrateOperation]rO   r   r  r  )r[  rM  rO   zIterator[Tuple[Any, ...]])rQ   rR   rS   rT   rU   r   rS  rW  r   rV  rY   r=   rC   r@   rM  rM  
  s8    75 )$)	") )rC   rM  c                  P   ^  \ rS rSrSrSS.       SU 4S jjjrS	S jrSrU =r$ )
ModifyTableOpsi'
  zCContains a sequence of operations that all apply to a single Table.Nr   c               <   > [         TU ]  U5        Xl        X0l        g rF   )r  r   r   r   )r?   r   rO  r   r  s       r@   r   ModifyTableOps.__init__*
  s     	$rC   c                    [        U R                  [        [        U R                   Vs/ s H  oR                  5       PM     sn5      5      U R                  S9$ s  snf )N)rO  r   )r_  r   rs  reversedrO  rI   r   r?   r   s     r@   rI   ModifyTableOps.reverse5
  sD    OOXdhh?hzz|h?@A;;
 	
?s   Ar  )r   r|   rO  r]  r   r   rO   r   )rO   r_  	rQ   rR   rS   rT   rU   r   rI   rY   r  r  s   @r@   r_  r_  '
  sE    M !%		 (	
 	 
	 	
 
rC   r_  c                  V   ^  \ rS rSrSr  S     SU 4S jjjrS	S jrS
S jrSrU =r	$ )
UpgradeOpsi=
  zcontains a sequence of operations that would apply to the
'upgrade' stream of a script.

.. seealso::

    :ref:`customizing_revision`

c                ,   > [         TU ]  US9  X l        g NrR  )r  r   upgrade_token)r?   rO  rk  r  s      r@   r   UpgradeOps.__init__G
  s    
 	S!*rC   c           	         [        [        U R                   Vs/ s H  o"R                  5       PM     sn5      5      UR                  S S & U$ s  snf rF   )rs  rc  rO  rI   )r?   downgrade_opsr   s      r@   reverse_intoUpgradeOps.reverse_intoO
  sC    #TXX6XrjjlX67 
!  7s   Ac                2    U R                  [        / S95      $ rj  )ro  DowngradeOpsr>   s    r@   rI   UpgradeOps.reverseU
  s      "!566rC   )rk  )r=   upgrades)rO  r]  rk  r|   rO   r   )rn  rr  rO   rr  )rO   rr  )
rQ   rR   rS   rT   rU   r   ro  rI   rY   r  r  s   @r@   rh  rh  =
  sE     +-'+'+ + 
	+ +7 7rC   rh  c                  L   ^  \ rS rSrSr  S     SU 4S jjjrSS jrSrU =r$ )	rr  iY
  zcontains a sequence of operations that would apply to the
'downgrade' stream of a script.

.. seealso::

    :ref:`customizing_revision`

c                ,   > [         TU ]  US9  X l        g rj  )r  r   downgrade_token)r?   rO  rw  r  s      r@   r   DowngradeOps.__init__c
  s    
 	S!.rC   c                    [        [        [        U R                   Vs/ s H  oR	                  5       PM     sn5      5      S9$ s  snf rj  )rh  rs  rc  rO  rI   rd  s     r@   rI   DowngradeOps.reversek
  s6    Xdhh?hzz|h?@A
 	
?s   A)rw  )r=   
downgrades)rO  r]  rw  r|   rO   r   )rO   rh  rf  r  s   @r@   rr  rr  Y
  s@     +-+/'/ / 
	/ /
 
rC   rr  c                  :   \ rS rSr% SrS\S'   S\S'   S\S'   S	\" 5       S	S	S	S	S	S
.                     SS jjr\SS j5       r	\	R                      SS j5       r	\SS j5       r\R                      SS j5       r\SS j5       r\SS j5       rSrg	)MigrationScriptiq
  a4  represents 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_onc               |    Xl         X@l        XPl        X`l        Xpl        Xl        Xl        Xl        X l        X0l	        g rF   )
rev_idr  r  r  r  r  r  r  upgrade_opsrn  )r?   r  r  rn  r  r  r  r  r  r  r  s              r@   r   MigrationScript.__init__
  s:     	(($&*rC   c                    [        U R                  5      S:  a  [        S5      eU R                  (       d  gU R                  S   $ )zbAn instance of :class:`.UpgradeOps`.

.. seealso::

    :attr:`.MigrationScript.upgrade_ops_list`
r   zrThis MigrationScript instance has a multiple-entry list for UpgradeOps; please use the upgrade_ops_list attribute.Nr   )lenr  r   r>   s    r@   r  MigrationScript.upgrade_ops
  sH     t  !A%. 
 ""$$Q''rC   c                    [         R                  " U5      U l        U R                   H  n[        U[        5      (       a  M   e   g rF   )r   to_listr  
isinstancerh  )r?   r  elems      r@   r  r  
  s8     !LL5%%DdJ//// &rC   c                    [        U R                  5      S:  a  [        S5      eU R                  (       d  gU R                  S   $ )zfAn instance of :class:`.DowngradeOps`.

.. seealso::

    :attr:`.MigrationScript.downgrade_ops_list`
r   zvThis MigrationScript instance has a multiple-entry list for DowngradeOps; please use the downgrade_ops_list attribute.Nr   )r  r  r   r>   s    r@   rn  MigrationScript.downgrade_ops
  sH     t""#a'0 
 $$&&q))rC   c                    [         R                  " U5      U l        U R                   H  n[        U[        5      (       a  M   e   g rF   )r   r  r  r  rr  )r?   rn  r  s      r@   rn  r  
  s8     #ll=9''DdL1111 (rC   c                    U R                   $ )zA 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    r@   upgrade_ops_list MigrationScript.upgrade_ops_list
  s        rC   c                    U R                   $ )zA 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    r@   downgrade_ops_list"MigrationScript.downgrade_ops_list
  s     """rC   )r  r  r  r  rn  r  r  r  r  r  r  r  )r  r   r  rh  rn  rr  r  r   r  zSet[str]r  r   r  r  r  Optional[_RevIdType]r  r   r  r  rO   r   )rO   zOptional[UpgradeOps])r  z#Union[UpgradeOps, List[UpgradeOps]]rO   r   )rO   zOptional[DowngradeOps])rn  z'Union[DowngradeOps, List[DowngradeOps]]rO   r   )rO   r  )rO   r  )rQ   rR   rS   rT   rU   rX   setr   r   r  setterrn  r  r  rY   r=   rC   r@   r}  r}  q
  sI   . "!""&& "&E"!%-1&*+/++  + $	+ + + + + ++ $+ )+ 
+2 ( ($ 0>0	0 0 * *$ 2D2	2 2 ! ! # #rC   r}  )]
__future__r   abcr   r  typingr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   sqlalchemy.typesr    r   baser   r   r   r   r   sqlalchemy.sqlr   sqlalchemy.sql.elementsr   r    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.revisionr4   r5   r7   r:   r8   register_operationrv   rj   r   r   r   r  r#  r*  r_  ri  r  r  r  r  r  r  r	  r2  r?  rM  r_  rh  rr  r}  r=   rC   r@   <module>r     s   "  	        !          %  !   )5,3215,.0:.+.:0+65204,Te,-" "@#8& #8L 01##$57NOr%' r% P 2r%j 34##4 (()ABt% t% C 5
t%n 9:## @ (()<=% % > ;
%D 34##4 (()ABZ% Z% C 5
Z%z 89##> (();<(()KL(()BC%o % D M = :%D ~.##N4HIV%$ V% J /V%r |,##L2DEw%" w% F -w%t ~.e%$ e% /e%P |,d" d -dN
# 
 ~.!%L !% /!%H 56##8jM< jM 7jMZ 34##4N9 N9 5N9b ~.##N4HI[&L [& J /[&|
 |,##L2DEa%, a% F -a%H }-##M3FG@%< @% H .@%F }-x# x .xv y)##I?{)# {) @ *{)|)" ).
[ 
,7 78
; 
0#& #rC   