
    LȂiX                        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
JrJr  S SKJr  S SKJrJrJr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KJrJ r J!r!  S SK"J#r#  S SK$J%r%  S SK&J'r'   " S S\
5      r(g)    N)	takewhile)apps)settings)BaseCommandCommandErrorno_translations)run_formatters)DEFAULT_DB_ALIASOperationalErrorconnectionsrouter)	Migration)MigrationAutodetector)MigrationLoader)SwappableTuple)MigrationOptimizer)InteractiveMigrationQuestionerMigrationQuestioner!NonInteractiveMigrationQuestioner)ProjectState)get_migration_name_timestamp)MigrationWriterc                   n    \ rS rSr\rSrS r\S 5       r	S r
\S 5       rS rSS	 jr\S
 5       rS rSrg)Command   z"Creates new migration(s) for apps.c                 f   UR                  SSSSS9  UR                  SSSS	9  UR                  S
SSS	9  UR                  SSSS	9  UR                  SSSSSS9  UR                  SSSS9  UR                  SSSSS9  UR                  SSSSS9  UR                  SSSS S9  UR                  S!SS"S#S9  g )$Nargs	app_label*z2Specify the app label(s) to create migrations for.)metavarnargshelpz	--dry-run
store_truezCJust show what migrations would be made; don't actually write them.)actionr"   z--mergez%Enable fixing of migration conflicts.z--emptyzCreate an empty migration.z	--noinputz
--no-inputstore_falseinteractivez:Tells Django to NOT prompt the user for input of any kind.)r$   destr"   z-nz--namez$Use this name for migration file(s).)r"   z--no-headerinclude_headerz4Do not add header comments to new migration file(s).z--checkcheck_changeszuExit with a non-zero status if model changes are missing migrations and don't actually write them. Implies --dry-run.z--scriptable
scriptableziDivert log output and input prompts to stderr, writing only paths of generated migration files to stdout.z--updateupdatezTMerge model changes into the latest migration and optimize the resulting operations.)add_argument)selfparsers     _D:\sksbv-state-backend\venv\Lib\site-packages\django/core/management/commands/makemigrations.pyadd_argumentsCommand.add_arguments   sI   E	 	 	
 	V 	 	

 	8 	 	

 	- 	 	

 	 M 	 	
 	7 	 	

 	 !G	 	 	
 	 D 	 	
 	@ 	 	
 	( 	 	
    c                 T    U R                   (       a  U R                  $ U R                  $ N)r*   stderrstdout)r-   s    r/   
log_outputCommand.log_outputb   s    "oot{{>4;;>r2   c                 :    U R                   R                  U5        g r4   )r7   write)r-   msgs     r/   logCommand.logf   s    c"r2   c                 
  ^ / U l         US   U l        US   U l        US   U l        US   U l        US   U l        US   U l        U R                  (       a*  U R                  R                  5       (       d  [        S5      eUS   U l	        US	   nU(       a  S
U l        US   U l
        US   U l        U R                  (       a  S U R                  l        [        U5      nSnU H  n [        R                   " U5        M     U(       a  [(        R*                  " S5        [-        S S
S9n[        R.                  " 5        Vs1 sH  oR0                  iM     n	n[2        R4                  (       a  [6        O[8        /n
[;        U
5       HO  n[6        U   mTR<                  S   S:w  d  M!  [?        U4S jU	 5       5      (       d  M=   URA                  T5        MQ     URK                  5       nU(       a*  URM                  5        VVs0 sH  u  p^XQ;   d  M  X^_M     nnnU(       aE  U R                  (       d4  SRO                  S URM                  5        5       5      n[        SU-  5      eU R                  (       a  U(       d  U RQ                  S5        g U R                  (       a  U(       a  U RS                  X}5      $ U R                  (       a   [U        UU R                  U RV                  S9nO*[Y        UU R                  U R                  U RP                  S9nU R[                  UR]                  5       [^        R`                  " [        5      U5      nU R
                  (       af  U(       d  [        S5      eU Vs0 sH  nU[c        SU5      /_M     nnURe                  UURf                  U R                  S9nU Ri                  U5        g URk                  URf                  U=(       d    S U=(       d    S U R                  S9nU(       d  U R                  S:  ao  U(       aV  [m        U5      S:X  a#  U RQ                  S URo                  5       -  5        g U RQ                  S!S"RO                  U5      -  5        g U RQ                  S#5        g g U R                  (       a  U Rq                  U5        OU Ri                  U5        U(       a  [(        R*                  " S5        g g ! ["         a2  nU R                  R%                  ['        U5      5        S
n S nAGM&  S nAff = fs  snf ! [B         a/  n[D        RF                  " SU< SU< 3[H        5         S nAGM  S nAff = fs  snnf s  snf )$N	verbosityr&   dry_runmergeemptynamez5The migration name must be a valid Python identifier.r(   r)   Tr*   r+   F   )ignore_no_migrationsENGINEzdjango.db.backends.dummyc              3      >#    U Hc  n[         R                  " U5      R                  5        H8  n[        R                  " TR
                  XR                  R                  S 9v   M:     Me     g7f))
model_nameN)r   get_app_config
get_modelsr   allow_migratealias_metaobject_name).0r   model
connections      r/   	<genexpr>!Command.handle.<locals>.<genexpr>   sa      X
 ":I!00;FFHE	 $$$$iKK<S<S I	 ":s   A*A-zXGot an error checking a consistent migration history performed for database connection 'z': z; c              3   T   #    U H  u  pS R                  U5      < SU< 3v   M!     g7f), z in N)join)rO   appnamess      r/   rR   rS      s$      !GXdii.4GXs   &(zConflicting migrations detected; multiple leaf nodes in the migration graph: (%s).
To fix them run 'python manage.py makemigrations --merge'zNo conflicts detected to merge.)specified_appsr@   prompt_output)rY   r@   r?   r<   z:You must supply at least one app label when using --empty.custom)changesgraphmigration_name)r]   trim_to_appsconvert_appsr^      zNo changes detected in app '%s'z No changes detected in apps '%s'z', 'zNo changes detected)9written_filesr?   r&   r@   rA   rB   r^   isidentifierr   r(   r*   r+   r5   
style_funcsetr   rI   LookupErrorr:   strsysexitr   get_app_configslabelr   DATABASE_ROUTERSr   r
   sortedsettings_dictanycheck_consistent_historyr   warningswarnRuntimeWarningdetect_conflictsitemsrV   r<   handle_merger   r7   r   autodetectorproject_stater   	from_appsr   arrange_for_graphr]   write_migration_filesr\   lenpopwrite_to_last_migration_files)r-   
app_labelsoptionsr)   has_bad_labelsr   errloaderconfigconsistency_check_labelsaliases_to_checkrL   error	conflictsconflictname_str
questionerrw   rW   r\   rQ   s                       @r/   handleCommand.handlei   s    -"=1y)W%
W%
%fot':':'G'G'I'IVWW%&670DL!,/h'??%)DKK" _
#I&##I. $ HHQK !DA @D?S?S?U#V?UVLL?U #V $44K;K:L 	 ,-E$U+J''15OOTW X
 ":X U U33J? .( ++-	  ,5??+<+<'I* $	#+<   TZZyy !GPGX! H <>FG  ::iHH67 ::)$$V777)"ooJ ;)..HH	J ((  """4(
 ::"P  CMM*3sYx566*GM"44ll#22 5 G
 &&w/ &&,,#+t#+t..	 ' 
 ~~":!+!BZ^^EU!UV>%{{:68
 HH23 # {{227;**73 G  &!!#c(+!%& $W" ( MMHMuV& l NsH   &S>T?T>
UU/U
T&TT
U#U		Uc           	         [        [        [           5      n0 n0 nUR                  5        GH  u  pVUR                  R                  US9n[        U5      S:X  a  [        SU S35      eUS   nUR                  R                  U   n	U	R                  (       a  [        SU	 S35      eXR                  ;   a  [        SU	 S35      eUR                  R                  5        V
s/ sH  n
XR                  ;   d  M  U
PM     nn
U(       a7  SR                  U V
s/ sH	  n
S	U
 S	3PM     sn
5      n[        S
U	 SU S35      eU H  n
U	R                  R!                  U
R                  5        U
R                   H  n[#        U[$        5      (       aX  [&        R(                  UR*                  :X  a  U	R                  R-                  S5        MS  U	R                  R-                  U5        Mp  US   U
R.                  :w  d  M  U	R                  R-                  U5        M     M     [1        5       nUR3                  U	R                  U5      U	l        [5        U	5      R6                  nU R8                  =(       d    U	R;                  5       nU	R<                  S S SU 3-   nU	R<                  U:X  a  U	R<                  S-   nOUnUU	l        U	/X5'   XU'   GM     U R?                  X45        g s  sn
f s  sn
f )N)rW   r   zApp z0 has no migration, cannot update last migration.z Cannot update squash migration 'z'.z!Cannot update applied migration 'rU   'zCannot update migration 'z' that migrations z depend on.)__setting__AUTH_USER_MODEL   __updated) r   r   r
   ru   r]   
leaf_nodesr|   r   nodesreplacesapplied_migrationsdisk_migrationsvaluesdependenciesrV   
operationsextend
isinstancer   r   r   settingappendr   r   optimizer   pathr^   suggest_namerC   r{   )r-   r\   r   new_changesupdate_previous_migration_pathsr   app_migrationsleaf_migration_nodesleaf_migration_nodeleaf_migration	migrationdepending_migrationsformatted_migrations
dependency	optimizerprevious_migration_pathname_fragmentsuggested_namenew_names                      r/   r~   %Command.write_to_last_migration_files
  s    -=!>?*,')0%I#)<<#:#:y#:#I '(A-"9+%UV  #7q"9#\\//0CDN &&"6~6FbI  #&?&??"77GrJ 
 "(!7!7!>!>!@$!@I&*@*@@ !@ ! $
 $'+yy7KL7K)q1%7KL($ #//??Q+,K9 
 ,	))001E1EF"+"8"8J!*n==#33z7I7II*77>> B +77>>zJ#A)*=*==&33:::F #9 , +,I(1(:(:))9)N% '6n&E&J&J# //P>3N3N3PM+00!4=/7JJN""n4)..;)"*N&4%5K"9PI6 *9B 	"";P[$ Ms    K6KK 
Nc                 L   0 nUR                  5        GH]  u  pEU R                  S:  a-  U R                  U R                  R	                  SU-  5      5        U GH  n[        X`R                  5      nU R                  S:  a  U R                  UR                  5      nU R                  SU R                  R                  U5      -  5        UR                   H%  n	U R                  SU	R                  5       -  5        M'     U R                  (       a  U R                  R                  U5        U R                  (       Gd  [         R                  R#                  UR                  5      n
UR%                  U5      (       dw  [         R&                  " U
SS9  [         R                  R)                  U
S5      n[         R                  R+                  U5      (       d  [-        US5      R/                  5         SX4'   UR1                  5       n[-        UR                  SS	S
9 nUR                  U5        U R2                  R5                  UR                  5        SSS5        U(       a  X$   nU R                  U5      nUR6                  (       aO  U R                  UR                  5      nU R                  U R                  R9                  SU SU S35      5        GMz  [         R:                  " U5        U R                  SU 35        GM  GM  U R                  S:X  d  GM  U R                  U R                  R	                  SUR<                  -  5      5        U R                  UR1                  5       5        GM     GM`     [?        U R2                  U R@                  S9  g! , (       d  f       GNM= f)z<
Take a changes dict and write them out as migration files.
ra   zMigrations for '%s':z  %s
    %sT)exist_okz__init__.pywutf-8encodingNzUpdated migration z- requires manual porting.
Previous migration z? was kept and must be deleted after porting functions manually.zDeleted    zFull migrations file '%s':r5   )!ru   r?   r<   styleMIGRATE_HEADINGr   r(   get_relative_pathr   MIGRATE_LABELr   formatted_descriptionr*   r6   r:   r@   osdirnamegetmakedirsrV   isfileopenclose	as_stringrb   r   needs_manual_portingWARNINGremovefilenamer	   r5   )r-   r\   r   directory_createdr   r   r   writermigration_string	operationmigrations_directory	init_pathfh	prev_pathrel_prev_pathmigration_paths                   r/   r{   Command.write_migration_filesQ  s    )0%I~~"334JY4VWX+	(4G4GH>>Q& (,'='=fkk'J$HHX

(@(@AQ(RRS%.%9%9	I,K,K,M!MN &:))*:;|||+-77??6;;+G(,00;;$84H$&GGLL1E}$U	!ww~~i88 C06687;)4'-'7'7'9$fkk3AR!12**11&++> B 7$C$N	(,(>(>y(I!66-1-C-CFKK-PN HH $

 2 2&88H I::G IX%Y!" IIi0 HHx%?@ 7  ^^q( HH

2286??J
 HHV--/0g , *9n 	t))$++>; BAs   7N
N#c                      [         R                  R                  U 5      nUR	                  S5      (       a  U nU$ ! [         a    U n N(f = f)Nz..)r   r   relpath
ValueError
startswith)r   r   s     r/   r   Command.get_relative_path  sP    	$!wwt4 &&t,,#	  	$#	$s   ; A
	A
c                 	  ^ U R                   (       a  [        U R                  S9nO[        SS0S9nUR	                  5        GHT  u  pE/ nU Hk  nTR                  XG5      nTR                  R                  XG45       V	s/ sH  n	U	S   UR                  :X  d  M  U	PM     sn	Ul	        UR                  U5        Mm     S n
[        S U 5       6 n[        S [        X5       5       5      nU(       d  [        S	U-  5      eU H>  nUR                  US
 Ul        U4S jUR                   5       n[        U/ 5      Ul        M@     U R"                  S:  a  U R%                  U R&                  R)                  SU-  5      5        U Ho  nU R%                  U R&                  R+                  SUR,                  -  5      5        UR                    H%  nU R%                  SUR/                  5       -  5        M'     Mq     UR1                  U5      (       d  GM  U Vs/ sH(  nU R2                  R5                  UR,                  5      PM*     nn [7        S U 5       5      n[9        S[:        4SU Vs/ sH  nXHR,                  4PM     sn05      nSUS-   -  /nU R<                  (       a  UR                  U R<                  5        OlUR                  S5        SR?                  [A        S U 5       5      5      n[C        U5      S:  a  UR                  [E        5       5        OUR                  U5        SR?                  U5      nU" Xt5      n[G        UU RH                  5      nU RJ                  (       d  [M        URN                  SSS9 nURQ                  URS                  5       5        S
S
S
5        [U        URN                  /U RV                  S9  U R"                  S:  aZ  U R%                  SURN                  -  5        U RX                  (       a(  U RZ                  RQ                  URN                  5        GM  GM  GM  U R"                  S:X  d  GM  U R%                  U R&                  R)                  SUR\                  -  5      5        U R%                  URS                  5       5        GMW     g
s  sn	f s  snf ! [         a    Sn GNbf = fs  snf ! , (       d  f       GN,= f)zr
Handles merging together conflicted migrations interactively,
if it's safe; otherwise, advises on how to fix it.
)rZ   	ask_mergeT)defaultsr   c                 4   ^  [        U 4S jT SS   5       5      $ )Nc              3   0   >#    U H  oTS    :H  v   M     g7f)r   N )rO   itemseqs     r/   rR   @Command.handle_merge.<locals>.all_items_equal.<locals>.<genexpr>  s     >gd3q6>gs   ra   )all)r   s   `r/   all_items_equal-Command.handle_merge.<locals>.all_items_equal  s    >c!"g>>>r2   c              3   6   #    U H  oR                   v   M     g 7fr4   )ancestry)rO   ms     r/   rR   'Command.handle_merge.<locals>.<genexpr>  s     0VEUEU   c              3   $   #    U H  nS v   M	     g7f)ra   Nr   )rO   common_ancestor_generations     r/   rR   r     s      (3. 3s   z$Could not find common ancestor of %sNc              3   \   >#    U H"  u  pTR                  X5      R                  v   M$     g 7fr4   )get_migrationr   )rO   node_app	node_namer   s      r/   rR   r     s,      "/?+ ((=HH/?s   ),z
Merging %sz  Branch %sr   c              3   ,   #    U H  oc  M  Uv   M     g 7fr4   r   )rO   xs     r/   rR   r     s     (MGqGs   	ra   r   r   z%04irA   r   c              3   6   #    U H  oR                   v   M     g 7fr4   )rC   )rO   r   s     r/   rR   r     s     P?O)~~?Or   /   r   r   r   r   z
Created new merge migration %sr   z Full merge migrations file '%s':)/r&   r   r7   r   ru   r   r]   forwards_planr   r   r   zipsumr   r   branchmerged_operationsr?   r<   r   r   r   rC   r   r   rw   parse_numbermaxtyper   r^   rV   rm   r|   r   r   r(   r@   r   r   r:   r   r	   r5   r*   r6   r   )r-   r   r   r   r   migration_namesmerge_migrationsr^   r   migr   merge_migrations_generationscommon_ancestor_countmigrations_opsr   numbersbiggest_numbersubclassparts
leaf_namesnew_migrationr   r   s    `                     r/   rv   Command.handle_merge  s4   
 7dooVJ,{D6IJJ*3//*;&I  ""1"00K	  &||999:UV&V1v!4!44 V&	"
 !''	2 #2? ,/0VEU0V+W($' (2;#3( %! ) :_L  .	#,#5#56K6L#M	 "/8/?/?" /2.".E	+ . ~~!33L94LMN!1IHHTZZ55minn6TUV%.%@%@	I,K,K,M!MN &A "2 ##I..
 &6%5	 %%229>>B%5  '%((MG(M%MN  L&-=)-=	 '7-=)	  >A#567&&LL!4!45LL)!$P?OPP"J :+%A%CDZ0!$% ( C(8K8KL||fkk3AR!1!1!34 B"FKK=E~~)!Cfkk!QR?? KK--fkk: + * ^^q( HH

22>P
 HHV--/0G +<&R " '%&N')0 BAs6   >RR.R!R&$R99 R>&R65R6>
S	)
r@   rB   r(   r&   rA   r^   r*   r+   r?   rb   r4   )__name__
__module____qualname____firstlineno__r   rw   r"   r0   propertyr7   r<   r   r   r~   r{   staticmethodr   rv   __static_attributes__r   r2   r/   r   r      sk    (L/DB
H ? ?# ^ ^@EQN<?|    m1r2   r   ))r   rh   rq   	itertoolsr   django.appsr   django.confr   django.core.management.baser   r   r   django.core.management.utilsr	   	django.dbr
   r   r   r   django.db.migrationsr   !django.db.migrations.autodetectorr   django.db.migrations.loaderr   django.db.migrations.migrationr   django.db.migrations.optimizerr   django.db.migrations.questionerr   r   r   django.db.migrations.stater   django.db.migrations.utilsr   django.db.migrations.writerr   r   r   r2   r/   <module>r$     sX    	 
      R R 7 M M * C 7 9 = 
 4 C 7l1k l1r2   