https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/db/migrations/operations/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/db/migrations/operations/__pycache__/models.cpython-310.pyc
o

3�a[��@s�ddlmZddlmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZddlmZmZmZd	d
�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�Z Gd#d$�d$e�Z!Gd%d&�d&e!�Z"Gd'd(�d(e!�Z#Gd)d*�d*e!�Z$Gd+d,�d,e!�Z%d-S).�)�models)�	Operation)�
ModelState)�normalize_together)�cached_property�)�AddField�
AlterField�FieldOperation�RemoveField�RenameField)�field_references�get_references�resolve_relationcCs6t�}|D]}||vrtd||f��|�|�qdS)Nz4Found duplicate value %s in CreateModel %s argument.)�set�
ValueError�add)�arg_name�objs�	used_vals�val�r�H/usr/lib/python3/dist-packages/django/db/migrations/operations/models.py�_check_for_duplicates
s
��rcs8eZdZdd�Zedd��Zdd�Z�fdd�Z�ZS)	�ModelOperationcCs
||_dS�N��name)�selfrrrr�__init__�
zModelOperation.__init__cC�
|j��Sr)r�lower�rrrr�
name_lower�
zModelOperation.name_lowercCs|��|jkSr�r"r$�rr�	app_labelrrr�references_modelszModelOperation.references_modelcst��||�p|�|j|�Sr)�super�reducer)r�r�	operationr(��	__class__rrr+"s�zModelOperation.reduce)	�__name__�
__module__�__qualname__rrr$r)r+�
__classcell__rrr.rrs
rcsreZdZdZgd�Zd�fdd�	Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
edd��Zdd�Z
�fdd�Z�ZS)�CreateModelzCreate a model's table.)�fields�options�managersNcsz||_|pi|_|p
tjf|_|pg|_t��|�tddd�|jD��tddd�|jD��tddd�|jD��dS)Nr5cs��|]\}}|VqdSrr��.0r�_rrr�	<genexpr>6��z'CreateModel.__init__.<locals>.<genexpr>�basescss8�|]}t|d�r
|jjn
t|t�r|��n|VqdS)�_metaN)�hasattrr?�label_lower�
isinstance�strr")r:�baserrrr<7s��
�r7csr8rrr9rrrr<<r=)	r5r6r�Modelr>r7r*rr)rrr5r6r>r7r.rrr.s


�zCreateModel.__init__cCsn|j|jd�}|jr|j|d<|jr|jtjfkr|j|d<|jr0|jdt��fgkr0|j|d<|jj	g|fS)N)rr5r6r>�objectsr7)
rr5r6r>rrEr7�Managerr/r2�r�kwargsrrr�deconstruct>s�


�zCreateModel.deconstructc
Cs6|�t||jt|j�t|j�t|j�t|j	���dSr)
�	add_modelrr�listr5�dictr6�tupler>r7�rr(�staterrr�state_forwardsOs
�zCreateModel.state_forwardscC�2|j�||j�}|�|jj|�r|�|�dSdSr��apps�	get_modelr�allow_migrate_model�
connection�alias�create_model�rr(�
schema_editor�
from_state�to_state�modelrrr�database_forwardsY��zCreateModel.database_forwardscC�2|j�||j�}|�|jj|�r|�|�dSdSr�rTrUrrVrWrX�delete_modelrZrrr�database_backwards^r`zCreateModel.database_backwardscCs d|j�dd�r
dnd|jfS)NzCreate %smodel %s�proxyFzproxy �)r6�getrr#rrr�describecs zCreateModel.describecCs|jSr�r$r#rrr�migration_name_fragmentfsz#CreateModel.migration_name_fragmentcCs�|��}||jkrdS||f}|jD]}|tjur,t|tjjtf�r,t	||�|kr,dSq|j
D]\}}t||jf||�r@dSq0dS)NTF)r"r$r>rrErBrD�	ModelBaserCrr5r
)rrr(r$�reference_model_tuplerD�_name�fieldrrrr)js

��zCreateModel.references_modelcst�t�r|j�jkr|j�dd�sgSt�t�r.|j�jkr.t�j|j	|j|j
|jd�gSt�t�r`|j�jkr`i|j��j�}�j
D]
}|�jvrQ|�|d�qDt|j|j	||j
|jd�gSt�t�r�|j�jkr�t|j|j	i|j��j�ji�|j
|jd�gSt�t�r�|j�jkr�t|j|j	i|j�d�ji�|j
|jd�gSt�t��r�|j�jk�r�t�t�r�t|j|j	�j�jfg|j|j
|jd�gSt�t�r�t|j�fdd�|j	D�|j|j
|jd�gSt�t��r7|j��}dD] }|�|d�}|�rttt�fdd	�|D���}|�r|||<q�|�d�}|�jk�r"|d=t|j�fd
d�|j	D�||j
|jd�gSt�t��r�|j��}dD]}|�|�}|�rY�fdd�|D�||<�qD|�d�}|�j k�rk�j|d<t|j�fd
d�|j	D�||j
|jd�gSt!��"�|�S)NreF)r5r6r>r7�order_with_respect_tocs(g|]\}}||�jkr�jn|f�qSr)rrn�r:�n�v�r-rr�
<listcomp>����z&CreateModel.reduce.<locals>.<listcomp>)�unique_together�index_togetherc3s&�|]}t�fdd�|D��VqdS)c3s�|]
}|�jkr|VqdSrri�r:�frsrrr<�s�z/CreateModel.reduce.<locals>.<genexpr>.<genexpr>N�rN�r:r5rsrrr<�s�
�z%CreateModel.reduce.<locals>.<genexpr>cs&g|]\}}|���jkr||f�qSrr&rprsrrrt�s
�cs"h|]
}t�fdd�|D���qS)c3s$�|]
}|�jkr�jn|VqdSr��old_name�new_namerxrsrrr<�s�"z/CreateModel.reduce.<locals>.<setcomp>.<genexpr>rzr{rsrr�	<setcomp>�s��z%CreateModel.reduce.<locals>.<setcomp>cs(g|]\}}|�jkr�jn||f�qSrr|rprsrrrt�ru)#rB�DeleteModelr$r6rg�RenameModel�old_name_lowerr4r~r5r>r7�AlterModelOptions�ALTER_OPTION_KEYS�popr�AlterTogetherOptionOperation�option_name�option_value�AlterOrderWithRespectToror
�model_name_lowerrrnr	r�copyr�filter�boolrr}r*r+)rr-r(r6�keyr��optionror.rsrr+|s�
���	

���	��	��	
��
	
���

��

���



��


���zCreateModel.reduce)NNN)r0r1r2�__doc__�serialization_expand_argsrrJrQr_rdrh�propertyrjr)r+r3rrr.rr4)s

r4c@�LeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
dd��ZdS)r�zDrop a model's table.cCsd|ji}|jjg|fS�Nr)rr/r2rHrrrrJ�s��zDeleteModel.deconstructcCs|�||j�dSr)�remove_modelr$rOrrrrQ�zDeleteModel.state_forwardscCrarrbrZrrrr_
r`zDeleteModel.database_forwardscCrRrrSrZrrrrdr`zDeleteModel.database_backwardscCsdS)NTrr'rrrr)szDeleteModel.references_modelcC�
d|jS)NzDelete model %srr#rrrrhr zDeleteModel.describecCr�)Nz	delete_%srir#rrrrjr%z#DeleteModel.migration_name_fragmentN)r0r1r2r�rJrQr_rdr)rhr�rjrrrrr��s
r�cs�eZdZdZ�fdd�Zedd��Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
edd��Z�fdd�Z�ZS)r�zRename a model.cs||_||_t��|�dSr)r}r~r*r)rr}r~r.rrr$szRenameModel.__init__cCr!r)r}r"r#rrrr�)r%zRenameModel.old_name_lowercCr!r)r~r"r#rrr�new_name_lower-r%zRenameModel.new_name_lowercC�|j|jd�}|jjg|fS)Nr|)r}r~r/r2rHrrrrJ1���zRenameModel.deconstructcCs�|j||jf��}|j|_||j||jf<||jf}d||jf}t�}t||�D]2\}}}	}
d}|
jr=|	��}||j	_
|
jrL|durH|	��}||j	_|r\||j|<|�
|j|jf�q*|j|dd�|�||j�|j||jdd�dS)Nz%s.%sT��delay)rr��cloner~rr�rr�to�remote_fieldr^�throughr5rr(r$�
reload_modelsr��reload_model)rr(rP�
renamed_model�old_model_tuple�new_remote_model�	to_reload�model_staterrn�	reference�
changed_fieldrrrrQ<s,

�zRenameModel.state_forwardscCs>|j�||j�}|�|jj|�r�|j�||j�}|�||jj	|jj	�|jj
D]0}|j|kr6|}||jf}	n
|j}|jjj
|jjjf}	|jj|	�j�|jj�}
|�||j|
�q't|jj|jj�}|D]9\}}
|
j|
jkss|
jjjjstqc|jj}|
jj}|�||jj	|jj	�|�||j�|jj�|j�|jj��qcdSdSr)rTrUr~rVrWrXr}�alter_db_tabler?�db_table�related_objects�
related_modelr�r(�
model_name�	get_fieldrnr�alter_field�zip�local_many_to_manyr^r�r��auto_created)rr(r[r\r]�	new_model�	old_model�related_objectr^�related_key�to_fieldr5�	old_field�	new_field�
old_m2m_model�
new_m2m_modelrrrr_WsX�
�������zRenameModel.database_forwardscCs\|j|j|_|_|j|j|_|_|�||||�|j|j|_|_|j|j|_|_dSr)r�r�r}r~r_�rr(r[r\r]rrrrd�s
zRenameModel.database_backwardscCs|��|jkp
|��|jkSr)r"r�r�r'rrrr)�s�zRenameModel.references_modelcC�d|j|jfS)NzRename model %s to %sr|r#rrrrh��zRenameModel.describecCr�)Nzrename_%s_%s)r�r�r#rrrrj��z#RenameModel.migration_name_fragmentcsHt|t�r|j|jkrt|j|j�gStt|��||�p#|�	|j|�Sr)
rBr�r�r�r}r~r*rr+r)r,r.rrr+�s
��	�zRenameModel.reduce)r0r1r2r�rrr�r�rJrQr_rdr)rhr�rjr+r3rrr.rr�!s 

3	
r�cseZdZ�fdd�Z�ZS)�ModelOptionOperationcs0t||jtf�r|j|jkr|gSt��||�Sr)rBr/r�r$r*r+r,r.rrr+�szModelOptionOperation.reduce)r0r1r2r+r3rrr.rr��sr�csTeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
dd��Z�ZS)�AlterModelTablezRename a model's table.c�||_t��|�dSr)�tabler*r)rrr�r.rrr��zAlterModelTable.__init__cCr�)N�rr�)rr�r/r2rHrrrrJ�r�zAlterModelTable.deconstructcCs.|j|j||jfjd<|j||jdd�dS)Nr�Tr�)r�rr$r6r�rOrrrrQ�szAlterModelTable.state_forwardsc	Cs�|j�||j�}|�|jj|�rH|j�||j�}|�||jj|jj�t	|jj
|jj
�D]\}}|jjjj
rG|�|jj|jjjj|jjjj�q,dSdSr)rTrUrrVrWrXr�r?r�r�r�r�r�r�)	rr(r[r\r]r�r�r�r�rrrr_�s$�

���z!AlterModelTable.database_forwardscC�|�||||�Sr�r_r�rrrrd�r�z"AlterModelTable.database_backwardscCs"d|j|jdur
|jfSdfS)NzRename table for %s to %sz	(default)r�r#rrrrh�s��zAlterModelTable.describecCr�)Nzalter_%s_tablerir#rrrrj�r%z'AlterModelTable.migration_name_fragment)
r0r1r2r�rrJrQr_rdrhr�rjr3rrr.rr��sr�csheZdZdZ�fdd�Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Ze
dd��Z�ZS)r�Ncs.|rtt|��}t||j|�t��|�dSr)rr�setattrr�r*r)rrr�r.rrr�sz%AlterTogetherOptionOperation.__init__cCst||j�Sr)�getattrr�r#rrrr��sz)AlterTogetherOptionOperation.option_valuecCs d|j|j|ji}|jjg|fSr�)rr�r�r/r2rHrrrrJ�s��z(AlterTogetherOptionOperation.deconstructcCs4|j||jf}|j|j|j<|j||jdd�dS�NTr�)rr$r�r6r�r��rr(rPr�rrrrQsz+AlterTogetherOptionOperation.state_forwardscCsp|j�||j�}|�|jj|�r6|j�||j�}t|d|j�}||t|j|jt	��t|j|jt	���dSdS)Nzalter_%s)
rTrUrrVrWrXr�r�r?r)rr(r[r\r]r�r��alter_togetherrrrr_s��z.AlterTogetherOptionOperation.database_forwardscCr�rr�r�rrrrdr�z/AlterTogetherOptionOperation.database_backwardscs,|�||�o|jpt�fdd�|jD��S)Nc3s�|]}�|vVqdSrrr{rrrr<r=z@AlterTogetherOptionOperation.references_field.<locals>.<genexpr>)r)r��any�rr�rr(rrr�references_fields�z-AlterTogetherOptionOperation.references_fieldcCsd|j|jt|jp
d�fS)Nz"Alter %s for %s (%s constraint(s))rf)r�r�lenr�r#rrrrh"sz%AlterTogetherOptionOperation.describecCr�)Nzalter_%s_%s)r$r�r#rrrrj%r�z4AlterTogetherOptionOperation.migration_name_fragment)r0r1r2r�rrr�rJrQr_rdr�rhr�rjr3rrr.rr��s
	r�c�$eZdZdZdZ�fdd�Z�ZS)�AlterUniqueTogetherz|
    Change the value of unique_together to the target one.
    Input value of unique_together must be a set of tuples.
    rvc�t��||�dSr�r*r)rrrvr.rrr1r�zAlterUniqueTogether.__init__�r0r1r2r�r�rr3rrr.rr�*�r�cr�)�AlterIndexTogetherzz
    Change the value of index_together to the target one.
    Input value of index_together must be a set of tuples.
    rwcr�rr�)rrrwr.rrr<r�zAlterIndexTogether.__init__r�rrr.rr�5r�r�cs`eZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zedd��Z
�ZS)r�z9Represent a change with the order_with_respect_to option.rocr�r)ror*r)rrror.rrrEr�z AlterOrderWithRespectTo.__init__cCr�)N�rro)rror/r2rHrrrrJIr�z#AlterOrderWithRespectTo.deconstructcCs2|j||jf}|j|jd<|j||jdd�dS)NroTr�)rr$ror6r�r�rrrrQT�z&AlterOrderWithRespectTo.state_forwardscCs�|j�||j�}|�|jj|�rI|j�||j�}|jjr,|jjs,|�||j�	d��dS|jjrK|jjsM|j�	d�}|�
�sAd|_|�||�dSdSdSdS)N�_orderr)
rTrUrrVrWrXr?ro�remove_fieldr��has_default�default�	add_field)rr(r[r\r]�to_model�
from_modelrnrrrr_Ys��z)AlterOrderWithRespectTo.database_forwardscCs|�||||�dSrr�r�rrrrdksz*AlterOrderWithRespectTo.database_backwardscCs |�||�o|jdup||jkSr)r)ror�rrrr�ns
�z(AlterOrderWithRespectTo.references_fieldcCr�)Nz%Set order_with_respect_to on %s to %sr�r#rrrrhwr�z AlterOrderWithRespectTo.describecCr�)Nzalter_%s_order_with_respect_torir#rrrrjzr%z/AlterOrderWithRespectTo.migration_name_fragment)r0r1r2r�r�rrJrQr_rdr�rhr�rjr3rrr.rr�@s	r�cs\eZdZdZgd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
edd��Z�Z
S)r�z�
    Set new model options that don't directly affect the database schema
    (like verbose_name, permissions, ordering). Python code in migrations
    may still need them.
    )�base_manager_name�default_manager_name�default_related_name�
get_latest_by�managed�ordering�permissions�default_permissions�select_on_save�verbose_name�verbose_name_pluralcr�r)r6r*r)rrr6r.rrr�r�zAlterModelOptions.__init__cCr�)N)rr6)rr6r/r2rHrrrrJ�r�zAlterModelOptions.deconstructcCs\|j||jf}i|j�|j�|_|jD]}||jvr"|j�|d�q|j||jdd�dS)NFTr�)rr$r6r�r�r�)rr(rPr�r�rrrrQ�s

�z AlterModelOptions.state_forwardscC�dSrrr�rrrr_��z#AlterModelOptions.database_forwardscCr�rrr�rrrrd�r�z$AlterModelOptions.database_backwardscCr�)NzChange Meta options on %srr#rrrrh�r zAlterModelOptions.describecCr�)Nzalter_%s_optionsrir#rrrrj�r%z)AlterModelOptions.migration_name_fragment)r0r1r2r�r�rrJrQr_rdrhr�rjr3rrr.rr�sr�csZeZdZdZdgZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
edd��Z�Z
S)�AlterModelManagerszAlter the model's managers.r7cr�r)r7r*r)rrr7r.rrr�r�zAlterModelManagers.__init__cCs|jj|j|jgifSr)r/r2rr7r#rrrrJ�s
�zAlterModelManagers.deconstructcCs2|j||jf}t|j�|_|j||jdd�dSr�)rr$rLr7r�r�rrrrQ�r�z!AlterModelManagers.state_forwardscCr�rrr�rrrr_�r�z$AlterModelManagers.database_forwardscCr�rrr�rrrrd�r�z%AlterModelManagers.database_backwardscCr�)NzChange managers on %srr#rrrrh�r zAlterModelManagers.describecCr�)Nzalter_%s_managersrir#rrrrj�r%z*AlterModelManagers.migration_name_fragment)r0r1r2r�r�rrJrQr_rdrhr�rjr3rrr.rr��sr�c@seZdZdZedd��ZdS)�IndexOperation�indexescCr!r)r�r"r#rrrr��r%zIndexOperation.model_name_lowerN)r0r1r2r�rr�rrrrr��sr�c@r�)�AddIndexzAdd an index on a model.cCs"||_|jstd|��||_dS)NzSIndexes passed to AddIndex operations require a name argument. %r doesn't have one.)r�rr�index)rr�r�rrrr�s��
zAddIndex.__init__cCsH|j||jf}g|j|j�|j���|j|j<|j||jdd�dSr�)rr�r6r�r�r�r�r�rrrrQ�s"zAddIndex.state_forwardscC�6|j�||j�}|�|jj|�r|�||j�dSdSr)rTrUr�rVrWrX�	add_indexr�rZrrrr_���zAddIndex.database_forwardscCs6|j�||j�}|�|jj|�r|�||j�dSdSr)rTrUr�rVrWrX�remove_indexr�rZrrrrd�r�zAddIndex.database_backwardscCr�)N)r�r�)r�r�r/r2rHrrrrJr�zAddIndex.deconstructcCsN|jjrd|jjd�dd�|jjD��|jfSd|jjd�|jj�|jfS)Nz!Create index %s on %s on model %sz, cSsg|]}t|��qSr)rC)r:�
expressionrrrrtsz%AddIndex.describe.<locals>.<listcomp>z*Create index %s on field(s) %s of model %s)r��expressionsr�joinr�r5r#rrrrhs��zAddIndex.describecC�d|j|jj��fS�Nz%s_%s)r�r�rr"r#rrrrj�z AddIndex.migration_name_fragmentN�r0r1r2r�rrQr_rdrJrhr�rjrrrrr��s	
r�c@r�)�RemoveIndexzRemove an index from a model.cC�||_||_dSr�r�r�rr�rrrrr �
zRemoveIndex.__init__c�L|j|�jf}|j�j}�fdd�|D�|j�j<|j|�jdd�dS)Nc�g|]
}|j�jkr|�qSrr)r:�idxr#rrrt'�z.RemoveIndex.state_forwards.<locals>.<listcomp>Tr��rr�r6r�r�)rr(rPr�r�rr#rrQ$�zRemoveIndex.state_forwardscCsP|j�||j�}|�|jj|�r&|j||jf}|�|j	�}|�
||�dSdSr)rTrUr�rVrWrXrr��get_index_by_namerr�)rr(r[r\r]r^�from_model_stater�rrrr_*��zRemoveIndex.database_forwardscC�P|j�||j�}|�|jj|�r&|j||jf}|�|j	�}|�
||�dSdSr)rTrUr�rVrWrXrr�r
rr�)rr(r[r\r]r^�to_model_stater�rrrrd1rzRemoveIndex.database_backwardscCr��Nr)r�rr/r2rHrrrrJ8r�zRemoveIndex.deconstructcCr�)NzRemove index %s from %s�rr�r#rrrrhCr�zRemoveIndex.describecC�d|j|j��fS�Nzremove_%s_%s�r�rr"r#rrrrjF�z#RemoveIndex.migration_name_fragmentNr�rrrrr�sr�c@r�)�
AddConstraint�constraintscCrr�r��
constraint)rr�rrrrrNrzAddConstraint.__init__cCsD|j||jf}g|j|j�|j�|j|j<|j||jdd�dSr�)rr�r6r�rr�r�rrrrQRszAddConstraint.state_forwardscCr�r)rTrUr�rVrWrX�add_constraintrrZrrrr_Wr�zAddConstraint.database_forwardscCr�r)rTrUr�rVrWrX�remove_constraintrrZrrrrd\r�z AddConstraint.database_backwardscC�|jjg|j|jd�fS)Nr)r/r0r�rr#rrrrJa��zAddConstraint.deconstructcCsd|jj|jfS)Nz Create constraint %s on model %s)rrr�r#rrrrhgr�zAddConstraint.describecCr�r�)r�rrr"r#rrrrjjr�z%AddConstraint.migration_name_fragmentN�r0r1r2r�rrQr_rdrJrhr�rjrrrrrKsrc@r�)�RemoveConstraintrcCrrrrrrrrrrzRemoveConstraint.__init__cr)Ncrrr)r:�cr#rrrtyrz3RemoveConstraint.state_forwards.<locals>.<listcomp>Tr�r)rr(rPr�rrr#rrQvr	zRemoveConstraint.state_forwardscCsP|j�||j�}|�|jj|�r&|j||jf}|�|j	�}|�
||�dSdSr)rTrUr�rVrWrXrr��get_constraint_by_namerr)rr(r[r\r]r^rrrrrr_|rz"RemoveConstraint.database_forwardscCr
r)rTrUr�rVrWrXrr�r rr)rr(r[r\r]r^rrrrrrd�rz#RemoveConstraint.database_backwardscCrr)r/r0r�rr#rrrrJ�rzRemoveConstraint.deconstructcCr�)Nz"Remove constraint %s from model %srr#rrrrh�r�zRemoveConstraint.describecCrrrr#rrrrj�rz(RemoveConstraint.migration_name_fragmentNrrrrrrosrN)&�	django.dbr�$django.db.migrations.operations.baser�django.db.migrations.stater�django.db.models.optionsr�django.utils.functionalrr5rr	r
rr�utilsr
rrrrr4r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr�<module>s6
R'6<?;#8.$

https://t.me/RX1948 - 2025