Ë
    ¹ûàg4  ã                   ó¬   — d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ ddlmZ  G d	„ d
«      Z G d„ de«      Z G d„ de«      Zy)é    N)Úapps)ÚOutputWrapper)ÚNOT_PROVIDED)Útimezone)Úget_docs_versioné   )ÚMigrationLoaderc                   óH   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zy)ÚMigrationQuestionerzË
    Give the autodetector responses to questions it might have.
    This base class has a built-in noninteractive mode, but the
    interactive subclass is what the command-line arguments will use.
    Nc                 óN   — |xs i | _         |xs
 t        «       | _        || _        y ©N)ÚdefaultsÚsetÚspecified_appsÚdry_run)Úselfr   r   r   s       ú]/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/django/db/migrations/questioner.pyÚ__init__zMigrationQuestioner.__init__   s#   € Ø š BˆŒØ,Ò5´³ˆÔØˆ�ó    c                 óþ  — || j                   v ry	 t        j                  |«      }t        j                  |j                  «      \  }}|€| j                  j                  dd«      S 	 t        j                  |«      }t        |dd«      r=t        j                  t        j                  j                  |j                   «      «      }nPt#        |d«      rDt%        |j&                  «      dkD  ryt        j                  t)        |j&                  «      d   «      }t+        d	„ D «       «       S # t        $ r | j                  j                  dd«      cY S w xY w# t,        $ r | j                  j                  dd«      cY S w xY w)
z2Should we create an initial migration for the app?TÚask_initialFNÚ__file__Ú__path__r   r   c              3   óJ   K  — | ]  }|d k7  sŒ	|j                  d«      –— Œ y­w)z__init__.pyz.pyN)Úendswith)Ú.0Úxs     r   ú	<genexpr>z2MigrationQuestioner.ask_initial.<locals>.<genexpr>7   s    è ø€ ÒV°À1ÈÓCU˜1Ÿ:™: e×,ÑVùs   ‚
#�#)r   r   Úget_app_configÚLookupErrorr   Úgetr	   Úmigrations_moduleÚlabelÚ	importlibÚimport_moduleÚgetattrÚosÚlistdirÚpathÚdirnamer   ÚhasattrÚlenr   ÚlistÚanyÚImportError)r   Ú	app_labelÚ
app_configÚmigrations_import_pathÚ_r"   Ú	filenamess          r   r   zMigrationQuestioner.ask_initial   sR  € ð ˜×+Ñ+Ñ+Øð
	;Ü×,Ñ,¨YÓ7ˆJô %4×$EÑ$EÀj×FVÑFVÓ$WÑ!Ð Ø!Ð)à—=‘=×$Ñ$ ]°EÓ:Ð:ð	WÜ )× 7Ñ 7Ð8NÓ OÐô Ð(¨*°dÔ;ÜŸJ™J¤r§w¡w§¡Ð7H×7QÑ7QÓ'RÓS‘	ÜÐ*¨JÔ7ÜÐ(×1Ñ1Ó2°QÒ6Ø ÜŸJ™J¤tÐ,=×,FÑ,FÓ'GÈÑ'JÓK�	ÜÑV°iÔVÓVÐVÐVøô# ò 	;Ø—=‘=×$Ñ$ ]°EÓ:Ò:ð	;ûô ò 	;Ø—=‘=×$Ñ$ ]°EÓ:Ò:ð	;ús#   ‘D) Á'E Ä)%EÅEÅ%E<Å;E<c                  ó   — y)ú#Adding a NOT NULL field to a model.N© ©r   Ú
field_nameÚ
model_names      r   Úask_not_null_additionz)MigrationQuestioner.ask_not_null_addition9   ó   € ð r   c                  ó   — y)ú"Changing a NULL field to NOT NULL.Nr7   r8   s      r   Úask_not_null_alterationz+MigrationQuestioner.ask_not_null_alteration>   r<   r   c                 ó:   — | j                   j                  dd«      S )úWas this field really renamed?Ú
ask_renameF©r   r!   )r   r:   Úold_nameÚnew_nameÚfield_instances        r   rB   zMigrationQuestioner.ask_renameC   s   € à�}‰}× Ñ  ¨uÓ5Ð5r   c                 ó:   — | j                   j                  dd«      S )úWas this model really renamed?Úask_rename_modelFrC   )r   Úold_model_stateÚnew_model_states      r   rI   z$MigrationQuestioner.ask_rename_modelG   s   € à�}‰}× Ñ Ð!3°UÓ;Ð;r   c                 ó:   — | j                   j                  dd«      S )z)Should these migrations really be merged?Ú	ask_mergeFrC   ©r   r0   s     r   rM   zMigrationQuestioner.ask_mergeK   s   € à�}‰}× Ñ  ¨eÓ4Ð4r   c                  ó   — y)ú(Adding an auto_now_add field to a model.Nr7   r8   s      r   Úask_auto_now_add_additionz-MigrationQuestioner.ask_auto_now_add_additionO   r<   r   c                  ó   — y)ú.Adding a unique field with a callable default.Nr7   r8   s      r   Ú$ask_unique_callable_default_additionz8MigrationQuestioner.ask_unique_callable_default_additionT   r<   r   )NNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r;   r?   rB   rI   rM   rQ   rT   r7   r   r   r   r      s5   „ ñóò
Wò<ò
ò
6ò<ò5òó
r   r   c                   ób   ‡ — e Zd Z	 dˆ fd„	Zdd„Zd„ Zdd„Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zˆ xZS )ÚInteractiveMigrationQuestionerc                 ón   •— t         ‰| �  |||¬«       |xs t        t        j                  «      | _        y ©N)r   r   r   )Úsuperr   r   ÚsysÚstdoutÚprompt_output)r   r   r   r   r`   Ú	__class__s        €r   r   z'InteractiveMigrationQuestioner.__init__[   s6   ø€ ô 	‰ÑØ¨nÀgð 	ô 	
ð +ÒG¬m¼C¿J¹JÓ.GˆÕr   c                 ó<  — | j                   j                  |› d�d¬«       t        «       }|s|�|S |r|d   j                  «       dvr@| j                   j                  dd¬«       t        «       }|sŒ*|d   j                  «       dvrŒ@|d   j                  «       dk(  S )Nú Ú ©Úendingr   ÚynzPlease answer yes or no: Úy)r`   ÚwriteÚinputÚlower)r   ÚquestionÚdefaultÚresults       r   Ú_boolean_inputz-InteractiveMigrationQuestioner._boolean_inputc   sš   € Ø×Ñ× Ñ  H :¨Q ¸Ð Ô;Ü“ˆÙ˜'Ð-ØˆNÙ˜F 1™IŸO™OÓ-°TÑ9Ø×Ñ×$Ñ$Ð%@ÈÐ$ÔLÜ“WˆFò ˜F 1™IŸO™OÓ-°TÒ9ð �a‰y�‰Ó  CÑ'Ð'r   c                 ó¬  — | j                   j                  |› «       t        |«      D ])  \  }}| j                   j                  d|dz   ›d|›�«       Œ+ | j                   j                  dd¬«       t        «       }	 	 t	        |«      }d|cxk  rt        |«      k  r|S  | j                   j                  dd¬«       t        «       }ŒK# t        $ r Y Œ3w xY w)	Nrc   r   z) zSelect an option: rd   re   r   zPlease select a valid option: )r`   ri   Ú	enumeraterj   Úintr,   Ú
ValueError)r   rl   ÚchoicesÚiÚchoicern   Úvalues          r   Ú_choice_inputz,InteractiveMigrationQuestioner._choice_inputm   sØ   € Ø×Ñ× Ñ  H :Ô/Ü" 7Ó+ò 	B‰IˆAˆvØ×Ñ×$Ò$°!°a³%¹Ð%@ÕAð	Bà×Ñ× Ñ Ð!5¸bÐ ÔAÜ“ˆØð!Ü˜F›�ð �uÔ,¤ G£Ò,Ø �Lð -à×Ñ×$Ñ$Ð%EÈbÐ$ÔQÜ“WˆFð øô ò Ùðús   Á=C Ã	CÃCc                 óˆ  — | j                   j                  d«       |r| j                   j                  d|› d�«       | j                   j                  d«       | j                   j                  d«       	 |rdj                  |«      }nd}| j                   j                  |d¬	«       t        «       }|s|r|}|s| j                   j                  d
«       n4|dk(  rt	        j
                  d«       n	 t        |i t        t        dœ«      S Œ–# t        t        f$ r(}| j                   j                  d|z  «       Y d}~Œ3d}~ww xY w)zÿ
        Prompt for a default value.

        The ``default`` argument allows providing a custom default value (as a
        string) which will be shown to the user and used as the return value
        if the user doesn't provide any other input.
        z/Please enter the default value as valid Python.zAccept the default 'z/' by pressing 'Enter' or provide another value.zxThe datetime and django.utils.timezone modules are available, so it is possible to provide e.g. timezone.now as a value.zType 'exit' to exit this promptz[default: {}] >>> z>>> rd   re   z;Please enter some code, or 'exit' (without quotes) to exit.Úexitr   )Údatetimer   zInvalid input: %sN)r`   ri   Úformatrj   r^   rz   Úevalr{   r   ÚSyntaxErrorÚ	NameError)r   rm   ÚpromptÚcodeÚes        r   Ú_ask_defaultz+InteractiveMigrationQuestioner._ask_default~   s<  € ð 	×Ñ× Ñ Ð!RÔSÙØ×Ñ×$Ñ$Ø& w ið 0)ð *ôð 	×Ñ× Ñ ðFô	
ð 	×Ñ× Ñ Ð!BÔCØÙØ-×4Ñ4°WÓ=‘à�Ø×Ñ×$Ñ$ V°BÐ$Ô7Ü“7ˆDÙ™GØ�ÙØ×"Ñ"×(Ñ(ØQõð ˜’Ü—‘˜•ðFÜ  b´xÌXÑ*VÓWÐWð# øô$ $¤YÐ/ò FØ×&Ñ&×,Ñ,Ð-@À1Ñ-D×EÑEûðFús   Ã1D
 Ä
EÄD<Ä<Ec                 ó¨   — | j                   sF| j                  d|› d|› d�ddg«      }|dk(  rt        j                  d«       y| j	                  «       S y)	r6   z.It is impossible to add a non-nullable field 'z' to z{ without specifying a default. This is because the database needs something to populate existing rows.
Please select a fix:úbProvide a one-off default now (will be set on all existing rows with a null value for this column)ú6Quit and manually define a default value in models.py.é   é   N©r   rx   r^   rz   rƒ   ©r   r9   r:   rv   s       r   r;   z4InteractiveMigrationQuestioner.ask_not_null_addition¦   ss   € à�|Š|Ø×'Ñ'Ø@ÀÀð MØ �\ð "'ð(ðBð MðóˆFð ˜Š{Ü—‘˜”ð ð ×(Ñ(Ó*Ð*Ør   c                 ó¾   — | j                   sQ| j                  d|› d|› d�g d¢«      }|dk(  rt        S |dk(  rt        j                  d«       y| j                  «       S y)r>   z-It is impossible to change a nullable field 'z' on zŠ to non-nullable without providing a default. This is because the database needs something to populate existing rows.
Please select a fix:)r…   zŠIgnore for now. Existing rows that contain NULL values will have to be handled manually, for example with a RunPython or RunSQL operation.r†   r‡   rˆ   N)r   rx   r   r^   rz   rƒ   rŠ   s       r   r?   z6InteractiveMigrationQuestioner.ask_not_null_alteration½   st   € à�|Š|Ø×'Ñ'Ø?À
¸|ð LØ �\ð "'ð(ò
	óˆFð" ˜Š{Ü#Ð#Ø˜1’Ü—‘˜”ð ð ×(Ñ(Ó*Ð*Ør   c                 ób   — d}| j                  ||||||j                  j                  fz  d«      S )rA   z(Was %s.%s renamed to %s.%s (a %s)? [y/N]F)ro   ra   rU   )r   r:   rD   rE   rF   Úmsgs         r   rB   z)InteractiveMigrationQuestioner.ask_renameÙ   sG   € à8ˆØ×"Ñ"ØàØØØØ×(Ñ(×1Ñ1ðñð ó

ð 
	
r   c                 ór   — d}| j                  ||j                  |j                  |j                  fz  d«      S )rH   z(Was the model %s.%s renamed to %s? [y/N]F)ro   r0   Úname)r   rJ   rK   r�   s       r   rI   z/InteractiveMigrationQuestioner.ask_rename_modelè   sB   € à8ˆØ×"Ñ"ØØ×(Ñ(¨/×*>Ñ*>À×@TÑ@TÐUñVàó
ð 	
r   c                 ó&   — | j                  dd«      S )Nz°
Merging will only work if the operations printed above do not conflict
with each other (working on different fields or models)
Should these migration branches be merged? [y/N]F)ro   rN   s     r   rM   z(InteractiveMigrationQuestioner.ask_mergeñ   s    € Ø×"Ñ"ðAð ó	
ð 	
r   c                 ó¬   — | j                   sH| j                  d|› d|› d�ddg«      }|dk(  rt        j                  d«       y
| j	                  d¬	«      S y
)rP   z#It is impossible to add the field 'z' with 'auto_now_add=True' to zf without providing a default. This is because the database needs something to populate existing rows.
zDProvide a one-off default now which will be set on all existing rowsr†   r‡   rˆ   ztimezone.now)rm   Nr‰   rŠ   s       r   rQ   z8InteractiveMigrationQuestioner.ask_auto_now_add_additionù   st   € à�|Š|Ø×'Ñ'Ø5°j°\ð B*Ø*4¨ð 6,ð-ð
$àLðó
ˆFð ˜Š{Ü—‘˜”ð ð ×(Ñ(°Ð(Ó@Ð@Ør   c                 ó¢   — | j                   sCt        «       }| j                  d|› d|› d�d|› d�dg«      }|dk(  rt        j                  d«       y	)
rS   z!Callable default on unique field ú.zO will not generate unique values upon migrating.
Please choose how to proceed:
z›Continue making this migration as the first step in writing a manual migration to generate unique values described here: https://docs.djangoproject.com/en/z=/howto/writing-migrations/#migrations-that-add-unique-fields.z)Quit and edit field options in models.py.r‡   rˆ   N)r   r   rx   r^   rz   )r   r9   r:   Úversionrv   s        r   rT   zCInteractiveMigrationQuestioner.ask_unique_callable_default_addition  su   € à�|Š|Ü&Ó(ˆGØ×'Ñ'Ø3°J°<¸qÀÀð M2ð 3ð9ð :A¸	ð BMðNð
 @ðó	ˆFð ˜Š{Ü—‘˜”Ør   )NNNNr   )rd   )rU   rV   rW   r   ro   rx   rƒ   r;   r?   rB   rI   rM   rQ   rT   Ú__classcell__©ra   s   @r   rZ   rZ   Z   s@   ø„ àNRõHó(òó"&FòPò.ò8
ò
ò
òö(r   rZ   c                   óB   ‡ — e Zd Z	 	 	 	 	 dˆ fd„	Zd„ Zd„ Zd„ Zd„ Zˆ xZS )Ú!NonInteractiveMigrationQuestionerc                 óF   •— || _         || _        t        ‰| �  |||¬«       y r\   )Ú	verbosityÚlogr]   r   )r   r   r   r   rš   r›   ra   s         €r   r   z*NonInteractiveMigrationQuestioner.__init__$  s.   ø€ ð #ˆŒØˆŒÜ‰ÑØØ)Øð 	õ 	
r   c           	      óZ   — | j                   dkD  r| j                  d|› d|› d|› d�«       y y )Nr   úField 'ú' on model 'z' not migrated: r“   )rš   r›   )r   r9   r:   Úreasons       r   Úlog_lack_of_migrationz7NonInteractiveMigrationQuestioner.log_lack_of_migration4  s;   € Ø�>‰>˜AÒØ�H‰HØ˜*˜ \°*°Ð=MØ�(˜!ðõð r   c                 óT   — | j                  ||d«       t        j                  d«       y )NzIit is impossible to add a non-nullable field without specifying a defaultrˆ   ©r    r^   rz   r8   s      r   r;   z7NonInteractiveMigrationQuestioner.ask_not_null_addition;  s(   € à×"Ñ"ØØðô	
ô 	�‰��r   c                 ó>   — | j                  d|› d|› d�«       t        S )Nr�   rž   z8' given a default of NOT PROVIDED and must be corrected.)r›   r   r8   s      r   r?   z9NonInteractiveMigrationQuestioner.ask_not_null_alterationE  s-   € à�‰Ø�j�\ ¨j¨\ð :2ð 3ô	
ô Ðr   c                 óT   — | j                  ||d«       t        j                  d«       y )NzUit is impossible to add a field with 'auto_now_add=True' without specifying a defaultrˆ   r¢   r8   s      r   rQ   z;NonInteractiveMigrationQuestioner.ask_auto_now_add_additionM  s(   € à×"Ñ"ØØð#ô	
ô 	�‰��r   )NNNr   N)	rU   rV   rW   r   r    r;   r?   rQ   r•   r–   s   @r   r˜   r˜   #  s-   ø„ ð ØØØØõ
ò òòör   r˜   )r{   r$   r'   r^   Údjango.appsr   Údjango.core.management.baser   Údjango.db.modelsr   Údjango.utilsr   Údjango.utils.versionr   Úloaderr	   r   rZ   r˜   r7   r   r   ú<module>r«      sM   ðÛ Û Û 	Û 
å Ý 5Ý )Ý !Ý 1å #÷Hñ HôVFÐ%8ô FôR2Ð(;õ 2r   