
    h                     b    S SK Jr  SSKJrJr   " S S\5      r " S S\5      r " S S	\5      rg
)    )router   )	OperationOperationCategoryc                   `    \ rS rSrSr\R                  rSS/rSS jr	S r
S rS	 rS
 rS rSrg)SeparateDatabaseAndState   a  
Take two lists of operations - ones that will be used for the database,
and ones that will be used for the state change. This allows operations
that don't support state change to have it applied, or have operations
that affect the state or not the database, or so on.
database_operationsstate_operationsNc                 D    U=(       d    / U l         U=(       d    / U l        g Nr
   r   )selfr
   r   s      Y/var/www/html/env/lib/python3.13/site-packages/django/db/migrations/operations/special.py__init__!SeparateDatabaseAndState.__init__   s    #6#<"  0 6B    c                     0 nU R                   (       a  U R                   US'   U R                  (       a  U R                  US'   U R                  R                  / U4$ )Nr
   r   )r
   r   	__class____qualname__r   kwargss     r   deconstruct$SeparateDatabaseAndState.deconstruct   sR    ##,0,D,DF()  )-)>)>F%&++R88r   c                 L    U R                    H  nUR                  X5        M     g r   r   state_forwardsr   	app_labelstatestate_operations       r   r   'SeparateDatabaseAndState.state_forwards        #44O**9<  5r   c                     U R                    H8  nUR                  5       nUR                  X5        UR                  XX45        UnM:     g r   )r
   cloner   database_forwards)r   r   schema_editor
from_stateto_statedatabase_operations         r   r&   *SeparateDatabaseAndState.database_forwards!   sI    "&":":!'')H--iB00* "J #;r   c                     0 nU R                    H(  nXEU'   UR                  5       nUR                  X5        M*     [        U R                   5       H  nUnXW   nUR	                  XX45        M     g r   )r
   r%   r   reverseddatabase_backwards)r   r   r'   r(   r)   	to_statesdbopr*   s           r   r.   +SeparateDatabaseAndState.database_backwards+   sq    	,,D&dO~~'H	4 - #+4+C+C"D!J 4H11* #Er   c                     g)Nz(Custom state/database change combination r   s    r   describe!SeparateDatabaseAndState.describe<   s    9r   r   )NN)__name__
__module__r   __firstlineno____doc__r   MIXEDcategoryserialization_expand_argsr   r   r   r&   r.   r5   __static_attributes__r3   r   r   r   r      s>     !&&H!68J K79="":r   r   c                   t    \ rS rSrSr\R                  rSr SS jr	S r
\S 5       rS rS	 rS
 rS rS rSrg)RunSQL@   z
Run some raw SQL. A reverse SQL statement may be provided.

Also accept a list of operations that represent the state change effected
by this SQL change, in case it's custom column/table creation/deletion.
 Nc                 h    Xl         X l        U=(       d    / U l        U=(       d    0 U l        XPl        g r   )sqlreverse_sqlr   hintselidable)r   rD   rE   r   rF   rG   s         r   r   RunSQL.__init__K   s,     & 0 6B[b
 r   c                    SU R                   0nU R                  b  U R                  US'   U R                  (       a  U R                  US'   U R                  (       a  U R                  US'   U R                  R
                  / U4$ )NrD   rE   r   rF   )rD   rE   r   rF   r   r   r   s     r   r   RunSQL.deconstructT   su    488
 '$($4$4F=!  )-)>)>F%&::"jjF7O++R88r   c                     U R                   S L$ r   )rE   r4   s    r   
reversibleRunSQL.reversible`   s    t++r   c                 L    U R                    H  nUR                  X5        M     g r   r   r   s       r   r   RunSQL.state_forwardsd   r#   r   c                     [         R                  " UR                  R                  U40 U R                  D6(       a  U R                  X R                  5        g g r   )r   allow_migrate
connectionaliasrF   _run_sqlrD   r   r   r'   r(   r)   s        r   r&   RunSQL.database_forwardsh   sD    $$**I
9=
 MM-2
r   c                     U R                   c  [        S5      e[        R                  " UR                  R
                  U40 U R                  D6(       a  U R                  X R                   5        g g Nz!You cannot reverse this operation)rE   NotImplementedErrorr   rQ   rR   rS   rF   rT   rU   s        r   r.   RunSQL.database_backwardsn   s^    #%&IJJ$$**I
9=
 MM-)9)9:
r   c                     g)NzRaw SQL operationr3   r4   s    r   r5   RunSQL.describev   s    "r   c                    [        U[        [        45      (       aZ  U HS  nS n[        U[        [        45      (       a$  [        U5      nUS:X  a  Uu  p4O[	        SU-  5      eUR                  X4S9  MU     g U[        R                  :w  a?  UR                  R                  R                  U5      nU H  nUR                  US S9  M     g g )N   zExpected a 2-tuple but got %d)params)
isinstancelisttuplelen
ValueErrorexecuter@   nooprR   opsprepare_sql_script)r   r'   sqlsrD   r_   elements
statements	statements           r   rT   RunSQL._run_sqly   s    dT5M**cD%=11"3xH1}&)V()H8)STT%%c%9  V[[ &1155HHNJ'	%%i%= ( !r   )rG   rF   rE   rD   r   NNNF)r7   r8   r   r9   r:   r   SQLr<   rf   r   r   propertyrL   r   r&   r.   r5   rT   r>   r3   r   r   r@   r@   @   sW     !$$HD RW!
9 , ,=3;#>r   r@   c                   ~    \ rS rSrSr\R                  rSr SS jr	S r
\S 5       rS rS	 rS
 rS r\S 5       rSrg)	RunPython   zK
Run Python code in a context suitable for doing versioned ORM operations.
FNc                     X0l         [        U5      (       d  [        S5      eXl        Uc  S U l        O![        U5      (       d  [        S5      eX l        U=(       d    0 U l        XPl        g )Nz*RunPython must be supplied with a callablez2RunPython must be supplied with callable arguments)atomiccallablerd   codereverse_coderF   rG   )r   rw   rx   ru   rF   rG   s         r   r   RunPython.__init__   s^     ~~IJJ	 $DL)) !UVV ,[b
 r   c                     SU R                   0nU R                  b  U R                  US'   U R                  b  U R                  US'   U R                  (       a  U R                  US'   U R                  R
                  / U4$ )Nrw   rx   ru   rF   )rw   rx   ru   rF   r   r   r   s     r   r   RunPython.deconstruct   ss    DII
 (%)%6%6F>";;"#{{F8::"jjF7O++R88r   c                     U R                   S L$ r   )rx   r4   s    r   rL   RunPython.reversible   s      ,,r   c                     g r   r3   )r   r   r    s      r   r   RunPython.state_forwards   s     	r   c                     UR                  5         [        R                  " UR                  R                  U40 U R
                  D6(       a  U R                  UR                  U5        g g r   )clear_delayed_apps_cacher   rQ   rR   rS   rF   rw   appsrU   s        r   r&   RunPython.database_forwards   sT     	++-$$**I
9=
 IIjoo}5
r   c                     U R                   c  [        S5      e[        R                  " UR                  R
                  U40 U R                  D6(       a  U R                  UR                  U5        g g rX   )rx   rY   r   rQ   rR   rS   rF   r   rU   s        r   r.   RunPython.database_backwards   s`    $%&IJJ$$**I
9=
 joo}=
r   c                     g)NzRaw Python operationr3   r4   s    r   r5   RunPython.describe   s    %r   c                     g r   r3   )r   r'   s     r   rf   RunPython.noop   s    r   )ru   rw   rG   rF   rx   rn   )r7   r8   r   r9   r:   r   PYTHONr<   reduces_to_sqlr   r   rp   rL   r   r&   r.   r5   staticmethodrf   r>   r3   r   r   rr   rr      sf     !''HN JO!$
9 - -
6>&  r   rr   N)	django.dbr   baser   r   r   r@   rr   r3   r   r   <module>r      s5     .7:y 7:tG>Y G>TI	 Ir   