
    Evg(/                     8   d dl mZmZmZ d dlmZmZ d dlmZm	Z	m
Z
 d dlmZmZ d dlmZ  G d de          Z G d d	e          Z G d
 de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d d          Z G d dee	          Z G d dee
          Z G d de          Z G d  d!e          Z G d" d#e          Z G d$ d%e          Z G d& d'e          Z d(S ))    )get_citext_oidsget_hstore_oidsregister_type_handlers)NotSupportedErrorrouter)AddConstraintAddIndexRemoveIndex)	OperationOperationCategory)CheckConstraintc                   Z    e Zd ZdZej        Zd Zd Zd Z	d Z
d Zd Zed             Zd	S )
CreateExtensionTc                     || _         d S Nname)selfr   s     _/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/postgres/operations.py__init__zCreateExtension.__init__   s    			    c                     d S r    r   	app_labelstates      r   state_forwardszCreateExtension.state_forwards       r   c                    |j         j        dk    st          j        |j         j        |          sd S |                     || j                  s0|                    d|                    | j                  z             t          j
                     t          j
                     t          |j                    t          |j         d          r'|j                             |j         j         d           d S d S )N
postgresqlz!CREATE EXTENSION IF NOT EXISTS %sregister_geometry_adaptersT)
connectionvendorr   allow_migratealiasextension_existsr   execute
quote_namer   cache_clearr   r   hasattrr!   r   r   schema_editor
from_stateto_states        r   database_forwardsz!CreateExtension.database_forwards   s	   #*l::&BV$*IC
 C
: F$$]DI>> 	!!3**49556  
 	#%%%#%%% 	}7888=+-IJJ 	$??(3T    	 	r   c                 *   t          j        |j        j        |          sd S |                     || j                  r0|                    d|                    | j                  z             t          j	                     t          j	                     d S )NzDROP EXTENSION IF EXISTS %s)r   r$   r"   r%   r&   r   r'   r(   r   r)   r   r+   s        r   database_backwardsz"CreateExtension.database_backwards,   s    #M$<$BINN 	F  	:: 	!!-0H0H0S0SS   	#%%%#%%%%%r   c                     |j                                         5 }|                    d|g           t          |                                          cd d d            S # 1 swxY w Y   d S )Nz-SELECT 1 FROM pg_extension WHERE extname = %s)r"   cursorr'   boolfetchone)r   r,   	extensionr3   s       r   r&   z CreateExtension.extension_exists7   s    %,,.. 	+&NN?   ))**	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s   8AA#&A#c                     d| j         z  S )NzCreates extension %sr   r   s    r   describezCreateExtension.describe?   s    %	11r   c                     d| j         z  S )Nzcreate_extension_%sr   r8   s    r   migration_name_fragmentz'CreateExtension.migration_name_fragmentB   s    $ty00r   N)__name__
__module____qualname__
reversibler   ADDITIONcategoryr   r   r/   r1   r&   r9   propertyr;   r   r   r   r   r      s        J )H      ,	& 	& 	&+ + +2 2 2 1 1 X1 1 1r   r   c                       e Zd Zd ZdS )BloomExtensionc                     d| _         d S )Nbloomr   r8   s    r   r   zBloomExtension.__init__H   s    			r   Nr<   r=   r>   r   r   r   r   rD   rD   G   s#            r   rD   c                       e Zd Zd ZdS )BtreeGinExtensionc                     d| _         d S )N	btree_ginr   r8   s    r   r   zBtreeGinExtension.__init__M   s    			r   NrG   r   r   r   rI   rI   L   s#                 r   rI   c                       e Zd Zd ZdS )BtreeGistExtensionc                     d| _         d S )N
btree_gistr   r8   s    r   r   zBtreeGistExtension.__init__R   s     			r   NrG   r   r   r   rM   rM   Q   s#        ! ! ! ! !r   rM   c                       e Zd Zd ZdS )CITextExtensionc                     d| _         d S )Ncitextr   r8   s    r   r   zCITextExtension.__init__W       			r   NrG   r   r   r   rQ   rQ   V   #            r   rQ   c                       e Zd Zd ZdS )CryptoExtensionc                     d| _         d S )Npgcryptor   r8   s    r   r   zCryptoExtension.__init__\       			r   NrG   r   r   r   rW   rW   [   #            r   rW   c                       e Zd Zd ZdS )HStoreExtensionc                     d| _         d S )Nhstorer   r8   s    r   r   zHStoreExtension.__init__a   rT   r   NrG   r   r   r   r]   r]   `   rU   r   r]   c                       e Zd Zd ZdS )TrigramExtensionc                     d| _         d S )Npg_trgmr   r8   s    r   r   zTrigramExtension.__init__f   s    			r   NrG   r   r   r   ra   ra   e   s#            r   ra   c                       e Zd Zd ZdS )UnaccentExtensionc                     d| _         d S )Nunaccentr   r8   s    r   r   zUnaccentExtension.__init__k   rZ   r   NrG   r   r   r   re   re   j   r[   r   re   c                       e Zd Zd ZdS )NotInTransactionMixinc                 V    |j         j        rt          d| j        j        z            d S )Nz_The %s operation cannot be executed inside a transaction (set atomic = False on the migration).)r"   in_atomic_blockr   	__class__r<   r   r,   s     r   _ensure_not_in_transactionz0NotInTransactionMixin._ensure_not_in_transactionp   s?    #3 	#9;?>;RS  	 	r   N)r<   r=   r>   rn   r   r   r   ri   ri   o   s#            r   ri   c                   6    e Zd ZdZdZej        Zd Zd Z	d Z
dS )AddIndexConcurrentlyzDCreate an index using PostgreSQL's CREATE INDEX CONCURRENTLY syntax.Fc                 p    d| j         j        dd                    | j         j                  d| j        S )NzConcurrently create index z on field(s) , z
 of model )indexr   joinfields
model_namer8   s    r   r9   zAddIndexConcurrently.describe~   s:     JOOOIIdj'((((OO
 	
r   c                     |                      |           |j                            || j                  }|                     |j        j        |          r|                    || j        d           d S d S NT)concurrently)	rn   apps	get_modelrv   allow_migrate_modelr"   r%   	add_indexrs   r   r   r,   r-   r.   models         r   r/   z&AddIndexConcurrently.database_forwards   s}    ''666''	4?CC##M$<$BEJJ 	J##E4:D#IIIII	J 	Jr   c                     |                      |           |j                            || j                  }|                     |j        j        |          r|                    || j        d           d S d S rx   )	rn   rz   r{   rv   r|   r"   r%   remove_indexrs   r~   s         r   r1   z'AddIndexConcurrently.database_backwards   s}    ''666)))T_EE##M$<$BEJJ 	M&&udjt&LLLLL	M 	Mr   N)r<   r=   r>   __doc__atomicr   r@   rA   r9   r/   r1   r   r   r   rp   rp   x   s\        NNF )H
 
 
J J JM M M M Mr   rp   c                   6    e Zd ZdZdZej        Zd Zd Z	d Z
dS )RemoveIndexConcurrentlyzBRemove an index using PostgreSQL's DROP INDEX CONCURRENTLY syntax.Fc                 &    d| j         d| j        S )NzConcurrently remove index z from r   rv   r8   s    r   r9   z RemoveIndexConcurrently.describe   s     9=DOOTTr   c                 @   |                      |           |j                            || j                  }|                     |j        j        |          rH|j        || j        f         }|	                    | j
                  }|                    ||d           d S d S rx   )rn   rz   r{   rv   r|   r"   r%   modelsmodel_name_lowerget_index_by_namer   r   )r   r   r,   r-   r.   r   from_model_staters   s           r   r/   z)RemoveIndexConcurrently.database_forwards   s    ''666)))T_EE##M$<$BEJJ 	H)0D<Q1QR$66tyAAE&&ue$&GGGGG	H 	Hr   c                 @   |                      |           |j                            || j                  }|                     |j        j        |          rH|j        || j        f         }|	                    | j
                  }|                    ||d           d S d S rx   )rn   rz   r{   rv   r|   r"   r%   r   r   r   r   r}   )r   r   r,   r-   r.   r   to_model_staters   s           r   r1   z*RemoveIndexConcurrently.database_backwards   s    ''666''	4?CC##M$<$BEJJ 	E%_Y8M-MNN"44TY??E##E5t#DDDDD	E 	Er   N)r<   r=   r>   r   r   r   REMOVALrA   r9   r/   r1   r   r   r   r   r      s_        LLF (HU U UH H HE E E E Er   r   c                   4    e Zd ZddddZd Zd Zd Zd Zd	S )
CollationOperationlibcT)providerdeterministicc                >    || _         || _        || _        || _        d S r   )r   localer   r   )r   r   r   r   r   s        r   r   zCollationOperation.__init__   s%    	 *r   c                     d S r   r   r   s      r   r   z!CollationOperation.state_forwards   r   r   c                     | j         | j        d}| j        r| j        dk    r
| j        |d<   | j        du r
| j        |d<   | j        j        g |fS )N)r   r   r   r   Fr   )r   r   r   r   rl   r>   )r   kwargss     r   deconstructzCollationOperation.deconstruct   sh    )t{;;= 	/T]f44!%F:&&&*&8F?#N'
 	
r   c           	      n   d|                     | j                  i}| j        dk    r|                     | j                  |d<   | j        du rd|d<   |                    d|                     | j                  d                    d	 |                                D                       d
z             d S )Nr   r   r   Ffalser   z$CREATE COLLATION %(name)s (%(args)s)rr   c              3   *   K   | ]\  }}| d | V  dS )=Nr   ).0optionvalues      r   	<genexpr>z6CollationOperation.create_collation.<locals>.<genexpr>   sE       " ",9FEv''''" " " " " "r   )r   args)r(   r   r   r   r'   r   rt   items)r   r,   r   s      r   create_collationz#CollationOperation.create_collation   s    -224;??@=F"",77FFD&&$+D!2%00;;		 " "=AZZ\\" " "   	
 	
 	
 	
 	
r   c                 f    |                     d|                    | j                  z             d S )NzDROP COLLATION %s)r'   r(   r   rm   s     r   remove_collationz#CollationOperation.remove_collation   s<    -":":49"E"EE	
 	
 	
 	
 	
r   N)r<   r=   r>   r   r   r   r   r   r   r   r   r   r      sn        17t + + + + +  

 

 


 
 
 
 
 
 
 
r   r   c                   H    e Zd ZdZej        Zd Zd Zd Z	e
d             ZdS )CreateCollationzCreate a collation.c                     |j         j        dk    st          j        |j         j        |          sd S |                     |           d S Nr    )r"   r#   r   r$   r%   r   r+   s        r   r/   z!CreateCollation.database_forwards   S    #*l::&BV$*IC
 C
: Fm,,,,,r   c                 r    t          j        |j        j        |          sd S |                     |           d S r   )r   r$   r"   r%   r   r+   s        r   r1   z"CreateCollation.database_backwards   <    #M$<$BINN 	Fm,,,,,r   c                     d| j          S )NzCreate collation r   r8   s    r   r9   zCreateCollation.describe       .49...r   c                 :    d| j                                         z  S )Nzcreate_collation_%sr   lowerr8   s    r   r;   z'CreateCollation.migration_name_fragment       $ty'8'888r   N)r<   r=   r>   r   r   r@   rA   r/   r1   r9   rB   r;   r   r   r   r   r      sj         )H- - -- - -
/ / / 9 9 X9 9 9r   r   c                   H    e Zd ZdZej        Zd Zd Zd Z	e
d             ZdS )RemoveCollationzRemove a collation.c                     |j         j        dk    st          j        |j         j        |          sd S |                     |           d S r   )r"   r#   r   r$   r%   r   r+   s        r   r/   z!RemoveCollation.database_forwards   r   r   c                 r    t          j        |j        j        |          sd S |                     |           d S r   )r   r$   r"   r%   r   r+   s        r   r1   z"RemoveCollation.database_backwards   r   r   c                     d| j          S )NzRemove collation r   r8   s    r   r9   zRemoveCollation.describe  r   r   c                 :    d| j                                         z  S )Nzremove_collation_%sr   r8   s    r   r;   z'RemoveCollation.migration_name_fragment  r   r   N)r<   r=   r>   r   r   r   rA   r/   r1   r9   rB   r;   r   r   r   r   r      sj         (H- - -- - -
/ / / 9 9 X9 9 9r   r   c                   V     e Zd ZdZej        Z fdZd Zd Z	e
 fd            Z xZS )AddConstraintNotValidzg
    Add a table constraint without enforcing validation, using PostgreSQL's
    NOT VALID syntax.
    c                     t          |t                    st          d          t                                          ||           d S )Nz<AddConstraintNotValid.constraint must be a check constraint.)
isinstancer   	TypeErrorsuperr   )r   rv   
constraintrl   s      r   r   zAddConstraintNotValid.__init__  sL    *o66 	N   	Z00000r   c                 0    d| j         j        d| j        S )NzCreate not valid constraint 
 on model )r   r   rv   r8   s    r   r9   zAddConstraintNotValid.describe  s#     O   OO
 	
r   c                    |j                             || j                  }|                     |j        j        |          rF| j                            ||          }|r+|                    t          |          dz   d            d S d S d S )Nz
 NOT VALID)params)
rz   r{   rv   r|   r"   r%   r   
create_sqlr'   str)r   r   r,   r-   r.   r   constraint_sqls          r   r/   z'AddConstraintNotValid.database_forwards  s    )))T_EE##M$<$BEJJ 	W!_77}MMN W %%c.&9&9L&HQU%VVVVV	W 	WW Wr   c                 0    t                      j        dz   S )N
_not_valid)r   r;   )r   rl   s    r   r;   z-AddConstraintNotValid.migration_name_fragment)  s    ww.==r   )r<   r=   r>   r   r   r@   rA   r   r9   r/   rB   r;   __classcell__)rl   s   @r   r   r   
  s         
 !)H1 1 1 1 1
 
 
W W W > > > > X> > > > >r   r   c                   Z    e Zd ZdZej        Zd Zd Zd Z	d Z
d Zed             Zd Zd	S )
ValidateConstraintz&Validate a table NOT VALID constraint.c                 "    || _         || _        d S r   rv   r   )r   rv   r   s      r   r   zValidateConstraint.__init__3  s    $			r   c                 &    d| j         d| j        S )NzValidate constraint r   r   r8   s    r   r9   zValidateConstraint.describe7  s     7;yyy$//RRr   c                 *   |j                             || j                  }|                     |j        j        |          rR|                    d|                    |j        j	                  d|                    | j
                             d S d S )NzALTER TABLE z VALIDATE CONSTRAINT )rz   r{   rv   r|   r"   r%   r'   r(   _metadb_tabler   r~   s         r   r/   z$ValidateConstraint.database_forwards:  s    )))T_EE##M$<$BEJJ 	!!! ",,U[-ABBBB!,,TY777    	 	r   c                     d S r   r   r+   s        r   r1   z%ValidateConstraint.database_backwardsE  s    r   c                     d S r   r   r   s      r   r   z!ValidateConstraint.state_forwardsI  r   r   c                 l    | j                                         d| j                                        S )N
_validate_)rv   r   r   r8   s    r   r;   z*ValidateConstraint.migration_name_fragmentL  s0    #'?#8#8#:#:#:#:DIOO<M<M<MNNr   c                 :    | j         j        g | j        | j        dfS )Nr   )rl   r<   rv   r   r8   s    r   r   zValidateConstraint.deconstructP  s+    N#"o	 
 	
r   N)r<   r=   r>   r   r   
ALTERATIONrA   r   r9   r/   r1   r   rB   r;   r   r   r   r   r   r   .  s        00 +H  S S S	 	 	     O O XO
 
 
 
 
r   r   N)!django.contrib.postgres.signalsr   r   r   	django.dbr   r   django.db.migrationsr   r	   r
   $django.db.migrations.operations.baser   r   django.db.models.constraintsr   r   rD   rI   rM   rQ   rW   r]   ra   re   ri   rp   r   r   r   r   r   r   r   r   r   <module>r      s           
 0 / / / / / / / E E E E E E E E E E M M M M M M M M 8 8 8 8 8 881 81 81 81 81i 81 81 81v    _   
               
! ! ! ! ! ! ! !
    o   
    o   
    o   
       
       
       M M M M M0( M M M4E E E E E3[ E E E4)
 )
 )
 )
 )
 )
 )
 )
X9 9 9 9 9( 9 9 929 9 9 9 9( 9 9 92!> !> !> !> !>M !> !> !>H*
 *
 *
 *
 *
 *
 *
 *
 *
 *
r   