
    h4                         S SK r S SKrS SK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
5      r " S S\5      r " S S\5      rg)    N)apps)OutputWrapper)NOT_PROVIDED)timezone)get_docs_version   )MigrationLoaderc                   R    \ rS rSrSrSS jrS rS rS rS r	S	 r
S
 rS rS rSrg)MigrationQuestioner   z
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                 `    U=(       d    0 U l         U=(       d
    [        5       U l        X0l        g N)defaultssetspecified_appsdry_run)selfr   r   r   s       Q/var/www/html/env/lib/python3.13/site-packages/django/db/migrations/questioner.py__init__MigrationQuestioner.__init__   s!     B,5    c                 ,   XR                   ;   a  g [        R                  " U5      n[        R                  " UR                  5      u  p4Uc  U R                  R                  SS5      $  [        R                  " U5      n[        USS5      (       a>  [        R                  " [        R                  R                  UR                   5      5      nOW[#        US5      (       aF  [%        UR&                  5      S:  a  g[        R                  " [)        UR&                  5      S   5      n[+        S	 W 5       5      (       + $ ! [         a    U R                  R                  SS5      s $ f = f! [,         a    U R                  R                  SS5      s $ f = f)
z2Should we create an initial migration for the app?Task_initialFN__file____path__r   r   c              3   R   #    U  H  oS :w  d  M
  UR                  S5      v   M     g7f)z__init__.pyz.pyN)endswith).0xs     r   	<genexpr>2MigrationQuestioner.ask_initial.<locals>.<genexpr>7   s$     ViCU,1::e,,is   	'')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   MigrationQuestioner.ask_initial   sT    +++
	;,,Y7J %4$E$EjFVFV$W!!)==$$]E::	W ) 7 78N O (*d;;JJrww7H7Q7Q'RS	*J77(112Q6 JJt,=,F,F'G'JK	ViVVVV#  	;==$$]E::	;  	;==$$]E::	;s#   D> *E* >&E'&E'*&FFc                     g)#Adding a NOT NULL field to a model.N r   
field_name
model_names      r   ask_not_null_addition)MigrationQuestioner.ask_not_null_addition9        r   c                     g)"Changing a NULL field to NOT NULL.Nr;   r<   s      r   ask_not_null_alteration+MigrationQuestioner.ask_not_null_alteration>   rA   r   c                 :    U R                   R                  SS5      $ )Was this field really renamed?
ask_renameFr   r$   )r   r>   old_namenew_namefield_instances        r   rH   MigrationQuestioner.ask_renameC   s    }}  u55r   c                 :    U R                   R                  SS5      $ )Was this model really renamed?ask_rename_modelFrI   )r   old_model_statenew_model_states      r   rP   $MigrationQuestioner.ask_rename_modelG   s    }}  !3U;;r   c                 :    U R                   R                  SS5      $ )z)Should these migrations really be merged?	ask_mergeFrI   r   r3   s     r   rU   MigrationQuestioner.ask_mergeK   s    }}  e44r   c                     g)(Adding an auto_now_add field to a model.Nr;   r<   s      r   ask_auto_now_add_addition-MigrationQuestioner.ask_auto_now_add_additionO   rA   r   c                     g).Adding a unique field with a callable default.Nr;   r<   s      r   $ask_unique_callable_default_addition8MigrationQuestioner.ask_unique_callable_default_additionT   rA   r   )r   r   r   )NNN)__name__
__module____qualname____firstlineno____doc__r   r   r?   rD   rH   rP   rU   rZ   r^   __static_attributes__r;   r   r   r   r      s5    
W<

6<5
r   r   c                   r   ^  \ rS rSr SU 4S jjrSS jrS rSS jrS rS r	S r
S	 rS
 rS rS rSrU =r$ )InteractiveMigrationQuestionerZ   c                 p   > [         TU ]  XUS9  U=(       d    [        [        R                  5      U l        g N)r   r   r   )superr   r   sysstdoutprompt_output)r   r   r   r   rn   	__class__s        r   r   'InteractiveMigrationQuestioner.__init__[   s4     	g 	 	
 +GmCJJ.Gr   c                 \   U R                   R                  U S3SS9  [        5       nU(       d  Ub  U$ U(       a  US   R                  5       S;  aF  U R                   R                  SSS9  [        5       nU(       d  M-  US   R                  5       S;  a  MF  US   R                  5       S:H  $ )N  endingr   ynzPlease answer yes or no: y)rn   writeinputlower)r   questiondefaultresults       r   _boolean_input-InteractiveMigrationQuestioner._boolean_inputc   s      H:Q ;'-NF1IOO-T9$$%@$LWF &F1IOO-T9 ay C''r   c                    U R                   R                  U 5        [        U5       H+  u  p4U R                   R                  SUS-   < SU< 35        M-     U R                   R                  SSS9  [        5       n  [	        U5      nSUs=:  a  [        U5      ::  a   U$   O U R                   R                  SSS9  [        5       nMN  ! [         a     N2f = f)	Nrr   r   z) zSelect an option: rs   rt   r   zPlease select a valid option: )rn   rx   	enumeratery   intr/   
ValueError)r   r{   choicesichoicer}   values          r   _choice_input,InteractiveMigrationQuestioner._choice_inputm   s      H:/"7+IA$$!a%%@A ,  !5b A!F u,G, L -$$%Eb$QWF   s   =C
 

CCc                    U R                   R                  S5        U(       a  U R                   R                  SU S35        U R                   R                  S5        U R                   R                  S5         U(       a  SR                  U5      nOSnU R                   R                  USS	9  [        5       nU(       d	  U(       a  UnU(       d  U R                   R                  S
5        O6US:X  a  [        R
                  " S5        O [        U0 [        [        S.5      $ M  ! [        [        4 a(  nU R                   R                  SU-  5         SnAN5SnAff = f)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>>> rs   rt   z;Please enter some code, or 'exit' (without quotes) to exit.exitr   )datetimer   zInvalid input: %sN)rn   rx   formatry   rl   r   evalr   r   SyntaxError	NameError)r   r|   promptcodees        r   _ask_default+InteractiveMigrationQuestioner._ask_default~   s<    	  !RS$$&wi 0) * 	  F	
 	  !BC-44W=$$VB$77DG""((Q FbxX*VWW# $ $Y/ F&&,,-@1-DEEFs   	D# #E3EEc                     U R                   (       dH  U R                  SU SU S3SS/5      nUS:X  a  [        R                  " S5        gU R	                  5       $ g)	r:   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   r   rl   r   r   r   r=   r>   r   s       r   r?   4InteractiveMigrationQuestioner.ask_not_null_addition   ss    ||''@ M \ "'(B MF {  ((**r   c                     U R                   (       dT  U R                  SU SU S3/ SQ5      nUS:X  a  [        $ US:X  a  [        R                  " S5        gU R                  5       $ g)rC   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   zIgnore 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   r   r   rl   r   r   r   s       r   rD   6InteractiveMigrationQuestioner.ask_not_null_alteration   st    ||''?
| L \ "'(
	F" {##1  ((**r   c                 b    SnU R                  UUUUUUR                  R                  4-  S5      $ )rG   z(Was %s.%s renamed to %s.%s (a %s)? [y/N]F)r~   ro   r`   )r   r>   rJ   rK   rL   msgs         r   rH   )InteractiveMigrationQuestioner.ask_rename   sG    8""((11 

 
	
r   c                 r    SnU R                  UUR                  UR                  UR                  4-  S5      $ )rO   z(Was the model %s.%s renamed to %s? [y/N]F)r~   r3   name)r   rQ   rR   r   s       r   rP   /InteractiveMigrationQuestioner.ask_rename_model   sB    8""((/*>*>@T@TUV
 	
r   c                 &    U R                  SS5      $ )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)r~   rV   s     r   rU   (InteractiveMigrationQuestioner.ask_merge   s     ""A 	
 	
r   c                     U R                   (       dG  U R                  SU SU S3SS/5      nUS:X  a  [        R                  " S5        g
U R	                  SS	9$ g
)rY   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)r|   Nr   r   s       r   rZ   8InteractiveMigrationQuestioner.ask_auto_now_add_addition   st    ||''5j\ B**4 6,-
$L
F {  (((@@r   c                     U R                   (       dE  [        5       nU R                  SU SU S3SU S3S/5      nUS:X  a  [        R                  " S5        g	)
r]   z!Callable default on unique field .zO will not generate unique values upon migrating.
Please choose how to proceed:
zContinue 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   r   rl   r   )r   r=   r>   versionr   s        r   r^   CInteractiveMigrationQuestioner.ask_unique_callable_default_addition  su    ||&(G''3J<q M2 39 :A	 BMN
 @	F {r   )rn   )NNNNr   )rs   )r`   ra   rb   rc   r   r~   r   r   r?   rD   rH   rP   rU   rZ   r^   re   __classcell__ro   s   @r   rg   rg   Z   sE    NRH("&FP.8


( r   rg   c                   N   ^  \ rS rSr     SU 4S jjrS rS rS rS rSr	U =r
$ )	!NonInteractiveMigrationQuestioneri#  c                 <   > X@l         XPl        [        TU ]  UUUS9  g rj   )	verbositylogrk   r   )r   r   r   r   r   r   ro   s         r   r   *NonInteractiveMigrationQuestioner.__init__$  s*     #) 	 	
r   c           	      \    U R                   S:  a  U R                  SU SU SU S35        g g )Nr   Field '' on model 'z' not migrated: r   )r   r   )r   r=   r>   reasons       r   log_lack_of_migration7NonInteractiveMigrationQuestioner.log_lack_of_migration4  s;    >>AHH*\*=M(! r   c                 V    U R                  UUS5        [        R                  " S5        g )NzIit is impossible to add a non-nullable field without specifying a defaultr   r   rl   r   r<   s      r   r?   7NonInteractiveMigrationQuestioner.ask_not_null_addition;  s(    ""	
 	r   c                 >    U R                  SU SU S35        [        $ )Nr   r   z8' given a default of NOT PROVIDED and must be corrected.)r   r   r<   s      r   rD   9NonInteractiveMigrationQuestioner.ask_not_null_alterationE  s-    j\j\ :2 3	
 r   c                 V    U R                  UUS5        [        R                  " S5        g )NzUit is impossible to add a field with 'auto_now_add=True' without specifying a defaultr   r   r<   s      r   rZ   ;NonInteractiveMigrationQuestioner.ask_auto_now_add_additionM  s(    ""#	
 	r   )r   r   )NNNr   N)r`   ra   rb   rc   r   r   r?   rD   rZ   re   r   r   s   @r   r   r   #  s2     
  r   r   )r   r'   r*   rl   django.appsr   django.core.management.baser   django.db.modelsr   django.utilsr   django.utils.versionr   loaderr	   r   rg   r   r;   r   r   <module>r      sM      	 
  5 ) ! 1 #H HVF%8 FR2(; 2r   