+
    TjMB                       ^ RI t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
HtHtHtHtHt ^ RIHtHtHt ^ RIHtHt ^ R	IHt ^ R
IHt ^ RIHtHt ^ RIHt ] P@                  ! R4      t!R t"R t#R t$ ! R R4      t%R# )    N)datetime)chain)settings)
FieldError)ColumnsExpressionsForeignKeyName	IndexName	StatementTable)names_digestsplit_identifiertruncate_name)
DeferrableIndex)CompositePrimaryKey)Query)TransactionManagementErroratomic)timezonezdjango.db.backends.schemac                    V P                   pVP                  '       d   R# VP                  '       d   VP                  R.8X  d   R# VP                  VP                  9   # )zn
When altering the given field, must constraints on its model from the given
relation be temporarily dropped?
FNT)fieldmany_to_manyprimary_key	to_fieldsname)relationaltered_fieldr   s   && S/var/www/idalgo/venv/lib/python3.14/site-packages/django/db/backends/base/schema.py_is_relevant_relationr       sM    
 NNE   U__%>00    c           	      ~    \        V P                  P                  R RRR R7      \        P                  ! R4      R7      # )FT)forwardreverseinclude_hiddeninclude_parentsr   )key)sorted_meta_get_fieldsoperator
attrgettermodels   &r   _all_related_fieldsr/   *   sB    !	 	  	
 ' r!   c              #     a a"   \        V 3R  l\        S P                  4       4       V3R l\        SP                  4       4       4      pV F2  w  r4W43x  \        VP                  VP                  4       Rj  xL
  K4  	  R#  L
5i)c              3   P   <"   T F  p\        VS4      '       g   K  Vx  K  	  R # 5iNr    ).0obj	old_fields   & r   	<genexpr>+_related_non_m2m_objects.<locals>.<genexpr>;   $      	
;$S)4 C;   &
&c              3   P   <"   T F  p\        VS4      '       g   K  Vx  K  	  R # 5ir2   r3   )r4   r5   	new_fields   & r   r7   r8   @   r9   r:   N)zipr/   r.   _related_non_m2m_objectsremote_field)r6   r<   related_fieldsold_relnew_rels   ff   r   r>   r>   7   s      	
*9??;	

	
*9??;	
N ++    
 	
 	
 +	
s   A6B:B;Bc                     a  ] tR t^Nt o RtRtRtRtRtRt	Rt
RtR	tR
tRtRt]tRtRtRtRtRtRtRtRtRt]tRt]tRtRtRt]t Rt!Rt"Rt#Rt$Rt%]t&Rt'Rt(R t)R|R! lt*R" t+R# t,R~R$ lt-R% t.R& t/R' t0RR( lt1R) t2R* t3R+ t4R, t5R- t6R. t7]8R/ 4       t9R0 t:R1 t;R2 t<R3 t=R4 t>R5 t?R6 t@R7 tAR8 tBR9 tCR: tDR; tER< tFR= tGR> tHR? tIR@ tJRRA ltKRB tLRRC ltMRD tNRRE ltORRF ltPRG tQRH tRRI tSRJ tTRRL ltURRM ltVRN tWRO tXRPRRQRRRRKRSRKRTRRUR}RVRRWR}RXRRYRRZR/R[ ltYRR\ ltZR] t[R^ t\R_ t]R` t^RRa lt_Rb t`Rc taRd tbRe tcRf tdRg teRh tfRi tgRj thRRk ltiRRl ltjRRm ltkRRn ltlRRo ltmRp tnRq toRr tpRs tqRRt ltrRu tsRRv lttRw tuRx tvRRy ltwR~Rz ltxR{tyV tzR# )BaseDatabaseSchemaEditorz
This class and its subclasses are responsible for emitting schema-changing
statements to the databases - model creation/removal/alteration, field
renaming, index fiddling, and so on.
z'CREATE TABLE %(table)s (%(definition)s)z1ALTER TABLE %(old_table)s RENAME TO %(new_table)sz7ALTER TABLE %(table)s SET TABLESPACE %(new_tablespace)szDROP TABLE %(table)s CASCADEz:ALTER TABLE %(table)s ADD COLUMN %(column)s %(definition)sz!ALTER TABLE %(table)s %(changes)sz2ALTER COLUMN %(column)s TYPE %(type)s%(collation)sz%ALTER COLUMN %(column)s DROP NOT NULLz$ALTER COLUMN %(column)s SET NOT NULLz/ALTER COLUMN %(column)s SET DEFAULT %(default)sz$ALTER COLUMN %(column)s DROP DEFAULTz,ALTER TABLE %(table)s DROP COLUMN %(column)szDALTER TABLE %(table)s RENAME COLUMN %(old_column)s TO %(new_column)szFUPDATE %(table)s SET %(column)s = %(default)s WHERE %(column)s IS NULLz"UNIQUE (%(columns)s)%(deferrable)szCHECK (%(check)s)z.ALTER TABLE %(table)s DROP CONSTRAINT %(name)sz"CONSTRAINT %(name)s %(constraint)szPRIMARY KEY (%(columns)s)z?ALTER TABLE %(table)s ADD CONSTRAINT %(name)s CHECK (%(check)s)zbALTER TABLE %(table)s ADD CONSTRAINT %(name)s UNIQUE%(nulls_distinct)s (%(columns)s)%(deferrable)sz|ALTER TABLE %(table)s ADD CONSTRAINT %(name)s FOREIGN KEY (%(column)s) REFERENCES %(to_table)s (%(to_column)s)%(deferrable)sNzQCREATE INDEX %(name)s ON %(table)s (%(columns)s)%(include)s%(extra)s%(condition)szaCREATE UNIQUE INDEX %(name)s ON %(table)s (%(columns)s)%(include)s%(nulls_distinct)s%(condition)sz/ALTER INDEX %(old_name)s RENAME TO %(new_name)szDROP INDEX %(name)szGALTER TABLE %(table)s ADD CONSTRAINT %(name)s PRIMARY KEY (%(columns)s)zDROP PROCEDURE %(procedure)sz)COMMENT ON TABLE %(table)s IS %(comment)sz5COMMENT ON COLUMN %(table)s.%(column)s IS %(comment)sc                    Wn         W n        V P                  '       d   . V n        V P                   P                  P                  ;'       d    TV n        R # r2   )
connectioncollect_sqlcollected_sqlfeaturescan_rollback_ddlatomic_migration)selfrF   rG   r   s   &&&&r   __init__!BaseDatabaseSchemaEditor.__init__   sA    $&!#D $ 8 8 I I T Tfr!   c                    . V n         V P                  '       d?   \        V P                  P                  4      V n        V P                  P                  4        V # r2   )deferred_sqlrK   r   rF   alias	__enter__)rL   s   &r   rR   "BaseDatabaseSchemaEditor.__enter__   sA        !6!67DKKK!!#r!   c                    Vf&   V P                    F  pV P                  VR 4       K  	  V P                  '       d   V P                  P	                  WV4       R # R # r2   )rP   executerK   r   __exit__)rL   exc_type	exc_value	tracebacksqls   &&&& r   rV   !BaseDatabaseSchemaEditor.__exit__   sK    ((S$' )   KK  i@ !r!   c           	        V P                   '       gN   V P                  P                  '       d2   V P                  P                  P                  '       g   \        R4      h\        V4      p\        P                  RWRVRV/R7       V P                   '       d   VP                  4       P                  R4      '       d   RMRpVeI   V P                  P                  V\        \        V P                  V4      4      ,          V,           4       R# V P                  P                  W,           4       R# V P                  P!                  4       ;_uu_ 4       pVP#                  W4       RRR4       R#   + '       g   i     R# ; i)	z:Execute the given SQL statement, with optional parameters.ziExecuting DDL statements while in a transaction on databases that can't perform a rollback is prohibited.z%s; (params %r)paramsrZ   )extra; N)rG   rF   in_atomic_blockrI   rJ   r   strloggerdebugrstripendswithrH   appendtuplemapquote_valuecursorrU   )rL   rZ   r]   endingrk   s   &&&  r   rU    BaseDatabaseSchemaEditor.execute   s    
    ///OO,,===,? 
 #hs8VUC2P 	 	
 ::<0055R3F!""))5T%5%5v!>??6I ""))#,7''))Vs+ *)))s   E//F 	c                L    V P                   P                  P                  V4      # r2   )rF   ops
quote_name)rL   r   s   &&r   rp   #BaseDatabaseSchemaEditor.quote_name   s    ""--d33r!   c           
     	  a a SP                   P                   FX  pV Uu. uF  pSP                   P                  V4      NK   	  ppS P                  P	                  S P                  SV4      4       KZ  	  . p. pSP                   P                   EF  pS P                  SV4      w  rxVf   K  VP                  S P                  R7      p	V	R,          '       d"   VRS P                  V	,          ,           ,          pVP                  S P                  R7      p
V
'       d   VRV
,          ,          pVP                  V4       VP                  '       Ed3   VP                  '       Ed    VP                  P                  P                   P                   pVP                  P                  P                   P                  VP                  P"                  4      P$                  pS P&                  '       dE   VRS P&                  RS P)                  V4      RS P)                  V4      /,          ,           ,          pMRS P                  P*                  P,                  '       d-   S P                  P	                  S P/                  SVR4      4       VP	                  S P)                  VP$                  4      : RV: 24       VP1                  4       R9   g   EK=  S P                  P2                  P5                  SP                   P                   VP$                  4      pV'       g   EK  S P                  P                  V4       EK  	  . pV'       dJ   SP                   P6                   F.  pS P                  P	                  VP9                  SS 4      4       K0  	  M0VP                  VV 3R lSP                   P6                   4       4       SP                   P:                  p\=        V\>        4      '       d+   VP	                  S PA                  VPB                  4      4       S PD                  R	S P)                  SP                   P                   4      R
RPG                  R . VOVO 4       4      /,          pSP                   PH                  '       dR   S P                  P2                  PK                  SP                   PH                  4      pV'       d   VRV,           ,          pVV3# u upi )z-Take a model and return its table definition.rF   check z %sto_table	to_column_fk_%(to_table)s_%(to_column)sc              3   H   <"   T F  pVP                  SS4      x  K  	  R # 5ir2   )constraint_sql)r4   
constraintr.   rL   s   & r   r7   5BaseDatabaseSchemaEditor.table_sql.<locals>.<genexpr>  s(      #"9J ))%66"9s   "table
definition, c              3   L   "   T F  pV'       g   K  \        V4      x  K  	  R # 5ir2   )rb   )r4   	statements   & r   r7   r|   '  s"      $!AI I!As   
$$)	AutoFieldBigAutoFieldSmallAutoField)&r)   unique_together	get_fieldrP   rg   _create_unique_sqllocal_fields
column_sqldb_parametersrF   sql_check_constraintdb_type_suffixextendr?   db_constraintr.   db_table
field_namecolumnsql_create_inline_fkrp   rI   supports_foreign_keys_create_fk_sqlget_internal_typero   autoinc_sqlconstraints
create_sqlpk
isinstancer   _pk_constraint_sqlcolumnssql_create_tablejoindb_tablespacetablespace_sql)rL   r.   field_namesr   fieldscolumn_sqlsr]   r~   extra_params	db_paramscol_type_suffixrv   rw   r   constraint_sqlsr{   r   rZ   r   s   ff                 r   	table_sql"BaseDatabaseSchemaEditor.table_sql   s    !;;66K@KLuekk++E2FL$$T%<%<UF%KL 7 [[--E'+ue'D$J!++t+GI!!cD$=$=	$III
#22doo2NOeo55
MM,'!!!e&9&9&9 --3399BB!..44::DD&&11&  ,,,#(A(A"DOOH$=#T__Y%?E ) # J __--CCC%%,,++!5*J  OOELL1 &&( - 
 #oo11==KK((%,, ;%%,,[9e .p  $kk55
!!(()>)>ud)KL 6 "" #"'++"9"9# 
 [[^^b-..""4#:#:2::#FG##T__U[[%9%9:$)) $!A;!A!A$ '
 
 ;;$$$!__00??))N s^++F{y Ms   $Sc              #  ^  "   Vx  VP                  R 4      ;p'       d   V P                  V4      x  VP                  pVP                  4       '       d.   V P	                  V4      w  rRV	 2x  VP                  V
4       RpT;'       d?    V P                  V4      '       * ;'       d!    T;'       d    V P                  V4      '       * pV'       d   V P                  V4      pVen   RV P                  V4      ,           pV P                  P                  P                  '       d   WP                  V4      ,          x  MVx  VP                  V4       VP                  '       d;   VP                   '       g)   V P                  P                  P"                  '       d   RpVP$                  '       d*   V P'                  V4      w  rVP                  V4       Vx  M7V'       g   Rx  M*V P                  P                  P(                  '       g   Rx  VP                   '       d   Rx  MVP*                  '       d   Rx  VP,                  ;'       g    VP.                  P,                  pV'       db   V P                  P                  P0                  '       d<   VP*                  '       d*   V P                  P2                  P5                  VRR	7      x  V P                  P                  P6                  '       d4   VP8                  '       d    V P;                  VP8                  4      x  R# R# R# 5i)
	collationzDEFAULT FNTzNOT NULLNULLzPRIMARY KEYUNIQUE)inline)get_collate_sqlnullhas_db_defaultdb_default_sqlr   skip_defaultskip_default_on_altereffective_default_column_default_sqlrF   rI   requires_literal_defaultsprepare_defaultrg   empty_strings_allowedr   !interprets_empty_strings_as_nulls	generated_column_generated_sqlimplied_column_nulluniquer   r)   supports_tablespacesro   r   supports_comments_inline
db_comment_comment_sql)rL   column_db_typer]   r.   r   field_db_paramsinclude_defaultr   r   default_sqldefault_paramsdefault_valuecolumn_defaultgenerated_sqlgenerated_params
tablespaces   &&&&&&&         r   _iter_column_sql)BaseDatabaseSchemaEditor._iter_column_sql7  s~     '++K8898##I..zz!!*.*=*=e*D'K[M**MM.)#O  = =%%e,,= = ;;$44U;< 	  2259M(!+d.F.Fu.M!M??++EEE )+?+?+NNN((MM-0 '''%%%((JJJD???.2.H.H.O+MMM*+))===L\\\N((EEEKK,E,E
((===//%%44Z4MM??##<<<AQAQAQ##E$4$455 BR<s   AL-5L-L-)	L-3L-AL-%A L-&L-8%L-L-20L-#*L-L-$L-;L-L-1%L-L-)AL-8L-
#L-c           
         VP                  V P                  R7      pVR,          pVf   R# . pRP                  V P                  VVVVVV4      4      V3# )zn
Return the column definition for a field. The field must already have
had set_attributes_from_name() called.
rs   typeru   NN)r   rF   r   r   )rL   r.   r   r   r   r   r]   s   &&&&   r   r   #BaseDatabaseSchemaEditor.column_sqlz  sq      ---I(0!HH%%"##
 
 	
r!   c                    R# )zi
Some backends don't accept default values for certain columns types
(i.e. MySQL longtext and longblob).
F rL   r   s   &&r   r   %BaseDatabaseSchemaEditor.skip_default      
 r!   c                    R# )z
Some backends don't accept default values for certain columns types
(i.e. MySQL longtext and longblob) in the ALTER COLUMN statement.
Fr   r   s   &&r   r   .BaseDatabaseSchemaEditor.skip_default_on_alter  r   r!   c                    \        R4      h)zE
Only used for backends which have requires_literal_defaults feature
zsubclasses of BaseDatabaseSchemaEditor for backends which have requires_literal_defaults must provide a prepare_default() methodNotImplementedErrorrL   values   &&r   r   (BaseDatabaseSchemaEditor.prepare_default  s     "P
 	
r!   c                    R# )zx
Return the SQL to use in a DEFAULT clause. The resulting string should
contain a '%s' placeholder for a default value.
%sr   r   s   &&r   r   ,BaseDatabaseSchemaEditor._column_default_sql  s    
 r!   c                  a  ^ RI Hp VP                  p\        W24      '       d   S P	                  V4      MRp\        VP                  R7      pVP                  S P                  R7      pVP                  V4      w  rxS P                  P                  P                  '       d<   T\        ;QJ d    . V 3R lV 4       F  NK  	  5M! V 3R lV 4       4      ,          p. pWG,          V3# )z;Return the sql and params for the field's database default.)Valuez(%s)r-   rs   c              3   F   <"   T F  pSP                  V4      x  K  	  R # 5ir2   )r   r4   prL   s   & r   r7   :BaseDatabaseSchemaEditor.db_default_sql.<locals>.<genexpr>  s      I&Q!5!5a!8!8&   !)django.db.models.expressionsr   _db_default_expressionr   r   r   r.   get_compilerrF   compilerI   r   rh   )	rL   r   r   
db_defaultrZ   querycompilerr   r]   s	   f&       r   r   'BaseDatabaseSchemaEditor.db_default_sql  s    611
/9*/L/LD$$U+RX 	 EKK(%%%A&..z:??##=== 55 I& I55 I& IIIKF &((r!   c                @  a  VP                  S P                  4      w  r#VP                  '       d   RMRpS P                  P                  P                  '       d<   T\
        ;QJ d    . V 3R lV 4       F  NK  	  5M! V 3R lV 4       4      ,          pRpRV RV 2V3# )z3Return the SQL to use in a GENERATED ALWAYS clause.STOREDVIRTUALc              3   F   <"   T F  pSP                  V4      x  K  	  R # 5ir2   rj   r   s   & r   r7   ABaseDatabaseSchemaEditor._column_generated_sql.<locals>.<genexpr>  s!     3XQWAD4D4DQ4G4GQWr   zGENERATED ALWAYS AS (z) r   )r   rF   
db_persistrI   r   rh   )rL   r   expression_sqlr]   persistency_sqls   f&   r   r   .BaseDatabaseSchemaEditor._column_generated_sql  s    !&!4!4T__!E&+&6&6&6(I??##===+ee3XQW3Xee3XQW3X.XXNF&~&6b8IJFRRr!   c                d   V P                  4       '       d   V P                  4       pV# V P                  '       d   R pV# V P                  '       gC   V P                  '       d1   V P
                  '       d   V P                  4       R8X  d   RpV# Rp V# \        V RR4      '       g   \        V RR4      '       dv   V P                  4       pVR8X  d   \        P                  ! 4       pV# \        P                  ! 4       pVR8X  d   VP                  4       pV# VR	8X  d   VP                  4       pV# R pV# )
NBinaryFieldr!   r`   auto_nowFauto_now_addDateTimeField	DateField	TimeField)has_defaultget_defaultr   r   blankr   r   getattrr   nowr   datetime)r   defaultinternal_types   &  r   _effective_default+BaseDatabaseSchemaEditor._effective_default  s    '')G( ' ___G$ # 0K0K0K&&(M9    UJ..'%QV2W2W!335M/",,.  #,,. K/%llnG
 	 #k1%llnG  Gr!   c                X    VP                  V P                  V4      V P                  4      # )z2Return a field's effective database default value.)get_db_prep_saver  rF   r   s   &&r   r   *BaseDatabaseSchemaEditor.effective_default  s$    %%d&=&=e&DdooVVr!   c                    \        4       h)a(  
Return a quoted version of the value so it's safe to use in an SQL
string. This is not safe against injection from user code; it is
intended only for use in making SQL scripts or preparing default values
for particularly tricky backends (defaults are not user-defined,
though, so this is safe).
r   r   s   &&r   rj   $BaseDatabaseSchemaEditor.quote_value  s     "##r!   c           	        V P                  V4      w  r#T P                  Y#;'       g    R4       V P                  P                  P                  '       d   VP
                  P                  '       d(   V P                  VRVP
                  P                  4       V P                  P                  P                  '       g   VP
                  P                   Ff  pVP                  '       g   K  VP                  V P                  R7      pVR,          pV P                  ! V P                  WWdP                  4      !   Kh  	  V P                  P                  V P                  V4      4       VP
                  P                    FZ  pVP"                  P$                  P
                  P&                  '       g   K5  V P)                  VP"                  P$                  4       K\  	  R# )zZ
Create a table and any accompanying indexes or unique constraints for
the given `model`.
Nrs   r   )r   rU   rF   rI   supports_commentsr)   db_table_commentalter_db_table_commentr   r   r   r   _alter_column_comment_sqlrP   r   _model_indexes_sqllocal_many_to_manyr?   throughauto_createdcreate_model)rL   r.   rZ   r]   r   r   
field_types   &&     r   r  %BaseDatabaseSchemaEditor.create_model  s\   
 nnU+ 	S..D)??##555{{+++++E49U9UV??++DDD"[[55E'''*/*=*='+ +> + &5V%<
!;; %j:J:J 6 	  !8!8!?@ [[33E!!))//<<<!!%"4"4"<"<= 4r!   c                t   VP                   P                   FZ  pVP                  P                  P                   P                  '       g   K5  V P                  VP                  P                  4       K\  	  V P                  V P                  RV P                  VP                   P                  4      /,          4       \        V P                  4       Fc  p\        V\        4      '       g   K  VP                  VP                   P                  4      '       g   KH  V P                  P                  V4       Ke  	  R# )z!Delete a model from the database.r}   N)r)   r  r?   r  r  delete_modelrU   sql_delete_tablerp   r   listrP   r   r   references_tableremove)rL   r.   r   rZ   s   &&  r   r!  %BaseDatabaseSchemaEditor.delete_model  s     [[33E!!))//<<<!!%"4"4"<"<= 4
 	!!)=)=>	
 ))*C#y))c.B.B$$/ / !!((-	 +r!   c                    VP                   '       d)   V P                  P                  P                  '       g   R# V P	                  VP                  W4      RR7       R# )zAdd an index on a model.Nr]   )contains_expressionsrF   rI   supports_expression_indexesrU   r   rL   r.   indexs   &&&r   	add_index"BaseDatabaseSchemaEditor.add_index1  sF     &&&OO,,HHH 	U%%e24@r!   c                    VP                   '       d)   V P                  P                  P                  '       g   R# V P	                  VP                  W4      4       R# )zRemove an index from a model.N)r)  rF   rI   r*  rU   
remove_sqlr+  s   &&&r   remove_index%BaseDatabaseSchemaEditor.remove_index<  s@     &&&OO,,HHHU%%e23r!   c                   V P                   P                  P                  '       d:   V P                  V P	                  WP
                  VP
                  4      R R7       R # V P                  W4       V P                  W4       R # )Nr(  )rF   rI   can_rename_indexrU   _rename_index_sqlr   r1  r-  )rL   r.   	old_index	new_indexs   &&&&r   rename_index%BaseDatabaseSchemaEditor.rename_indexE  s`    ??##444LL&&unninnM  
 e/NN5,r!   c                b    VP                  W4      pV'       d   V P                  VRR7       R# R# )zAdd a constraint to a model.Nr(  )r   rU   rL   r.   r{   rZ   s   &&& r   add_constraint'BaseDatabaseSchemaEditor.add_constraintO  s,    ##E0 LLTL* r!   c                ^    VP                  W4      pV'       d   V P                  V4       R# R# )z!Remove a constraint from a model.N)r0  rU   r;  s   &&& r   remove_constraint*BaseDatabaseSchemaEditor.remove_constraintW  s&    ##E0LL r!   c           	        V Uu0 uF  p\        V4      kK  	  ppV Uu0 uF  p\        V4      kK  	  ppVP                  V4       F%  pV P                  VVRRRR/V P                  4       K'  	  VP                  V4       FL  pV Uu. uF  qP                  P                  V4      NK  	  ppV P                  V P                  W4      4       KN  	  R# u upi u upi u upi )z
Deal with a model changing its unique_together. The input
unique_togethers must be doubly-nested, not the single-nested
["foo", "bar"] format.
r   Tr   FN)rh   
difference_delete_composed_indexsql_delete_uniquer)   r   rU   r   )	rL   r.   old_unique_togethernew_unique_togetherr   oldsnewsr   r   s	   &&&&     r   alter_unique_together.BaseDatabaseSchemaEditor.alter_unique_together]  s     -@@,?&f,?@,?@,?&f,?@ood+F''46&&	 ,  ??40K@KLukk++E2FLLL00?@ 1 A@ Ms   CC#Cc           	        V Uu0 uF  p\        V4      kK  	  ppV Uu0 uF  p\        V4      kK  	  ppVP                  V4       F%  pV P                  VVRRRR/V P                  4       K'  	  VP                  V4       FN  pV Uu. uF  qP                  P                  V4      NK  	  ppV P                  V P                  WRR7      4       KP  	  R# u upi u upi u upi )z
Deal with a model changing its index_together. The input
index_togethers must be doubly-nested, not the single-nested
["foo", "bar"] format.
r,  Tr   F_idx)r   suffixN)rh   rB  rC  sql_delete_indexr)   r   rU   _create_index_sql)	rL   r.   old_index_togethernew_index_togetherr   rG  rH  r   r   s	   &&&&     r   alter_index_together-BaseDatabaseSchemaEditor.alter_index_togetherr  s     -??,>&f,>?,>?,>&f,>?ood+F''$%0%%	 ,  ??40K@KLukk++E2FLLL//V/TU 1 @? Ms   CC#Cc           
     l   VP                   P                   Uu0 uF  qUP                  kK  	  ppVP                   P                   Uu0 uF  qUP                  kK  	  ppV Uu. uF'  qP                   P	                  V4      P
                  NK)  	  p	pV P                  ! VV	3R Wg,          /VB p
VP                  R4      RJ di   V
'       da   V P                  P                  P                  '       d;   \        V P                  VP                   P                  V	RR7      4      pW9   d   V.p
\        V
4      ^8w  dE   \        R\        V
4      : RVP                   P                  : RRP!                  V	4      : R	24      hV P#                  V P%                  WAV
^ ,          4      4       R
# u upi u upi u upi )excluder   TFquoteFound wrong number (z) of constraints for (r   )N)r)   r   r   indexesr   r   _constraint_namesr   rF   rI   *allows_multiple_constraints_on_same_fieldsrb   _unique_constraint_namer   len
ValueErrorr   rU   _delete_constraint_sql)rL   r.   r   constraint_kwargsrZ   r{   meta_constraint_namesmeta_index_namesr   r   constraint_namesdefault_names   &&&&&       r   rC  /BaseDatabaseSchemaEditor._delete_composed_index  s   .3kk.E.E!
.E
OO.E 	 !
 ?Dkk>Q>QR>Q
OO>QRDJKF5;;((/66FK11
 *<
  	
 !!(+t3 ((SSS ,,U[[-A-A7RW,XL /$0>  A% ()KK((IIg&	  	T00=Ma=PQR?!
 SKs   F'F,!-F1c           	        W#8X  gJ   V P                   P                  P                  '       d&   VP                  4       VP                  4       8X  d   R# V P	                  V P
                  RV P                  V4      RV P                  V4      /,          4       V P                   F,  p\        V\        4      '       g   K  VP                  W#4       K.  	  R# )z#Rename the table a model points to.N	old_table	new_table)rF   rI   ignores_table_name_caselowerrU   sql_rename_tablerp   rP   r   r   rename_table_references)rL   r.   old_db_tablenew_db_tablerZ   s   &&&& r   alter_db_table'BaseDatabaseSchemaEditor.alter_db_table  s    'OO$$<<<""$(:(:(<<!!T__\:T__\:	
 $$C#y))++LG %r!   c           
     B   V P                   '       d   V P                  P                  P                  '       de   T P	                  V P                   R V P                  VP                  P                  4      RT P                  T;'       g    R4      /,          4       R# R# R# )r}   commentr`   N)	sql_alter_table_commentrF   rI   r  rU   rp   r)   r   rj   )rL   r.   old_db_table_commentnew_db_table_comments   &&&&r   r  /BaseDatabaseSchemaEditor.alter_db_table_comment  s|    '''DOO,D,D,V,V,VLL,,T__U[[-A-ABt//0D0J0JK -W'r!   c                    V P                  V P                  RV P                  VP                  P                  4      RV P                  V4      RV P                  V4      /,          4       R# )z)Move a model's table between tablespaces.r}   old_tablespacenew_tablespaceN)rU   sql_retablespace_tablerp   r)   r   )rL   r.   old_db_tablespacenew_db_tablespaces   &&&&r   alter_db_tablespace,BaseDatabaseSchemaEditor.alter_db_tablespace  sW    '')=)=> $//2C"D $//2C"D	
r!   c                	   VP                   '       dV   VP                  P                  P                  P                  '       d&   V P                  VP                  P                  4      # V P                  WRR7      w  r4Vf   R# VP                  V P                  R7      ;p'       d   VRV 2,          pVP                  V P                  R7      pVR,          '       d"   VRV P                  V,          ,           ,          pVP                  '       Ed   V P                  P                  P                  '       Ed   VP                  '       Ed   RpV P                  '       EdP   VP                  P                  P                  P                   pVP                  P                  P                  P#                  VP                  P$                  4      P&                  p	\)        VP                  P                   4      w  rTRV P                  RV P+                  WV4      R	V
'       d   R
V P-                  V
4      ,          MRRV P-                  VP&                  4      RV P-                  V4      RV P-                  V	4      RV P                  P.                  P1                  4       /,          ,           ,          pM+V P2                  P5                  V P7                  WV4      4       V P8                  RV P-                  VP                  P                   4      RV P-                  VP&                  4      RV/,          pT P;                  Y;'       g    R4       VP=                  4       '       g   V P?                  V4      '       gv   V PA                  V4      ec   V PC                  VRVRR7      w  rV PD                  RV P-                  VP                  P                   4      RV/,          pV P;                  W4       VPF                  '       d   V P                  P                  PH                  '       dZ   V P                  P                  PJ                  '       g4   VR,          pV P:                  ! V PM                  WWPF                  4      !   V P2                  PO                  V PQ                  W4      4       V P                  P                  PR                  '       d   V P                  PU                  4        R# R# )zw
Create a field on a model. Usually involves adding a column, but may
involve adding a table instead (for M2M fields).
T)r   Nrs   ru   rt   rx   r   	namespacez%s.r`   r   rv   rw   
deferrabler}   r~   dropchangesr   )+r   r?   r  r)   r  r  r   r   rF   r   r   rI   r   r   sql_create_column_inline_fkr.   r   r   r   r   r   _fk_constraint_namerp   ro   deferrable_sqlrP   rg   r   sql_create_columnrU   r   r   r   _alter_column_default_sqlsql_alter_columnr   r  r   r  r   _field_indexes_sqlconnection_persists_old_columnsclose)rL   r.   r   r~   r]   r   r   constraint_suffixrv   rw   r  _rZ   changes_sqlr  s   &&&            r   	add_field"BaseDatabaseSchemaEditor.add_field  s    %"4"4"<"<"B"B"O"O"O$$U%7%7%?%?@@!__U4_P
#22doo2NN?NAo.//J''4??'C	W# 9 9I EEEJ((>>>### @/// --3399BB!..44::DD&&11&   00D0DE	cD$D$DD44UCTU>G	 ::Rdooell; 9!; $//"5"5"D"D"F	H 	% 	 	
 !!((''6GH $$T__U[[%9%9:dooell3*(
 
 	S..D) $$&&..u55&&u-9"&"@"@tU #A #K '')=)=>;+ C LL% ((:::OO,,EEE"6*JLL//*.>.> 	  !8!8!FG??##CCCOO!!# Dr!   c                *   VP                   '       dV   VP                  P                  P                  P                  '       d&   V P                  VP                  P                  4      # VP                  V P                  R7      R,          f   R# VP                  '       dH   V P                  WP                  .RR7      pV F#  pV P                  V P                  W4      4       K%  	  V P                  RV P                  VP                  P                  4      RV P                  VP                  4      /,          pV P                  V4       V P                  P                  P                   '       d   V P                  P#                  4        \%        V P&                  4       Fn  p\)        V\*        4      '       g   K  VP-                  VP                  P                  VP                  4      '       g   KS  V P&                  P/                  V4       Kp  	  R# )zm
Remove a field from a model. Usually involves deleting a column,
but for M2Ms may involve deleting a table.
rs   r   NTforeign_keyr}   r   )r   r?   r  r)   r  r!  r   rF   r\  r   rU   _delete_fk_sqlsql_delete_columnrp   r   rI   r  r  r#  rP   r   r   references_columnr%  )rL   r.   r   fk_namesfk_namerZ   s   &&&   r   remove_field%BaseDatabaseSchemaEditor.remove_field)  s    %"4"4"<"<"B"B"O"O"O$$U%7%7%?%?@@$//:6BJ--ell^QU-VH#T00@A $ $$T__U[[%9%9:dooell3(
 
 	S??##CCCOO!!#))*C#y))c.C.C$$ell/ / !!((-	 +r!   c           
        V P                  W#4      '       g   R# VP                  V P                  R7      pVR,          pVP                  V P                  R7      pVR,          pRp	Vf   VP                  e   Vf#   VP                  f   \	        RV: RV: R24      hVf   Vf   VP                  P
                  '       d   VP                  P
                  '       ds   VP                  P
                  P                  P                  '       dC   VP                  P
                  P                  P                  '       d   V P                  WW44      # Vf   Vf   VP                  P
                  '       d   VP                  P
                  '       dc   VP                  P
                  P                  P                  '       g3   VP                  P
                  P                  P                  '       g   R# Ve   Vf   \	        RV: RV: R24      hVP                  VP                  8w  g.   VP                  '       d   VP                  VP                  8w  d   R	p	MMVP                  '       d<    VP                  V P                  4      p
VP                  V P                  4      pW8g  p	V	'       d   \	        R
V R24      hV P                  VVVVVVVV4       R#   \         d    R	p	 L@i ; i)z
Allow a field's type, uniqueness, nullability, default, column,
constraints, etc. to be modified.
`old_field` is required to compute the necessary changes.
If `strict` is True, raise errors if the old column does not match
`old_field` precisely.
Nrs   r   FzCannot alter field z into zT - they do not properly define db_type (are you using a badly-written custom field?)zr - they are not compatible types (you cannot alter to or from M2M fields, or add or remove through= on M2M fields)Tz7Modifying GeneratedFields is not supported - the field z6 must be removed and re-added with the new definition.)_field_should_be_alteredr   rF   r?   r`  r  r)   r  _alter_many_to_manyr   r   r   r   _alter_field)rL   r.   r6   r<   strictold_db_paramsold_typenew_db_paramsnew_typemodifying_generated_fieldold_field_sqlnew_field_sqls   &&&&&       r   alter_field$BaseDatabaseSchemaEditor.alter_fieldI  s    ,,YBB!//4??/K (!//4??/K ($)!!7!7!?!7!7!? i)   &&...**222**2288EEE**2288EEE ++EiPP &&...**222!..66<<III!..66<<III !1 .7	C 
   I$7$77I$8$8I<P<P$P(,%   K ) 7 7 H
 !* 7 7 H,9,J)$I) UH H 
 			
  1,0)1s   ,K K'&K'c                    V P                   P                  pVP                  V P                   4      pR VR&    W1P                  4       ,          V,          #   \         d     R# i ; i)__column_name__r   N)rF   data_type_check_constraintsdb_type_parametersr   KeyError)rL   r   r   check_constraintsdatas   &&&  r   _field_db_check(BaseDatabaseSchemaEditor._field_db_check  s_     !OOGG''8*X	$%<%<%>?$FF 		s   A A$#A$c	           	     r   \        4       p	V P                  P                  P                  '       d   VP                  '       d   VP
                  '       d   V P                  VVR0R7      '       d   V P                  WP                  .RR7      p
V'       dO   \        V
4      ^8w  d?   \        R\        V
4      : RVP                  P                  : RVP                  : 24      hV
 F?  pV	P                  VP                  34       V P                  V P                  W4      4       KA  	  VP                   '       d   VP                   '       d   V P#                  W#4      '       d   VP                  P$                   Uu0 uF  qP&                  kK  	  ppV P                  VVP                  .RRVR	7      pV'       dO   \        V4      ^8w  d?   \        R\        V4      : R
VP                  P                  : RVP                  : 24      hV F#  pV P                  V P)                  W4      4       K%  	  VP+                  R4      pVP+                  R4      pV P                  P                  P                  ;'       db    VP,                  ;'       d    VP,                  ;'       g)    VP                   ;'       d&    VP                   ;'       d    WE8g  ;'       g    VV8g  pV'       d}   \/        W#4       Fm  w  ppV P                  VP0                  VP2                  P                  .RR7      pV F.  pV P                  V P                  VP0                  V4      4       K0  	  Ko  	  VP4                  '       d   VP                   '       g   VP4                  '       d   VP                   '       d   VP                  P6                   Uu0 uF  pVP&                  kK  	  ppV P                  VVP                  .R\8        P:                  VR7      pV F$  pV P                  V P=                  VV4      4       K&  	  V P?                  W&4      pV P?                  W74      pVV8w  d   V'       d   VP                  P$                   Uu0 uF  qP&                  kK  	  ppV P                  VVP                  .RVR7      pV'       dO   \        V4      ^8w  d?   \        R\        V4      : RVP                  P                  : RVP                  : 24      hV F#  pV P                  V PA                  W4      4       K%  	  VP                  VP                  8w  d   V P                  V PC                  VP                  P                  W#V4      4       V PD                   FV  p\G        V\H        4      '       g   K  VPK                  VP                  P                  VP                  VP                  4       KX  	  . p. p. pVPM                  V P                  R7      p VPM                  V P                  R7      p!WE8w  gP   V V!8w  gI   VV8w  gB   V P                  P                  PN                  '       dU   VPP                  VPP                  8w  d:   V PS                  WW5VV4      w  p"p#VPU                  V"4       VPW                  V#4       VPY                  4       '       dT   VPY                  4       '       d   VPZ                  VPZ                  8w  d"   VPU                  V P]                  WV4      4       M9VPY                  4       '       d$   VPU                  V P]                  WVRR7      4       Rp$VP^                  '       d   VP^                  '       g~   VPY                  4       '       gh   V Pa                  V4      p%V Pa                  V4      p&V Pc                  V4      '       g/   V%V&8w  d(   V&e$   Rp$VPU                  V Pe                  WV4      4       VP^                  VP^                  8w  d,   V Pg                  WV4      p"V"'       d   VPU                  V"4       VPi                  4       ;'       g    VPY                  4       ;'       d&    VP^                  ;'       d    VP^                  '       * p'V'       g
   V'       Ed   V''       g
   VV,          pV P                  P                  Pj                  '       dB   V'       d:   \m        \o        V!  4      w  pp(RPq                  V4      \m        \s        V(!  4      3.pV FP  w  pp(V P                  V Pt                  RV Pw                  VP                  P                  4      RV/,          V(4       KR  	  V''       d   VPY                  4       '       g   Rp)X&.p(MV Py                  V4      w  p)p(V P                  V Pz                  RV Pw                  VP                  P                  4      RV Pw                  VP                  4      RV)/,          V(4       V FP  w  pp(V P                  V Pt                  RV Pw                  VP                  P                  4      RV/,          V(4       KR  	  V'       d   V F  w  pp(V P                  VV(4       K  	  VP,                  '       d$   VP,                  '       g   V P}                  W4       V P                  W#4      '       d"   V P                  V P                  W.4      4       VP4                  '       d   VP                   '       dG   VP4                  '       d5   VP                   '       g#   V P                  V P                  W.R7      4       . p*V'       d   V*PW                  \/        W#4      4       V P#                  W#4      '       d;   V P                  V P                  W4      4       V*PW                  \/        W#4      4       V* EF5  w  p+pVP2                  P                  V P                  R7      p,V,R,          p-V,P+                  R4      p.V+P2                  P                  V P                  R7      p/V/P+                  R4      p0V PS                  VP0                  V+P2                  VP2                  V-V0V.4      w  p"p#V P                  V Pt                  RV Pw                  VP0                  P                  P                  4      RV"^ ,          /,          V"^,          4       V# F  w  pp(V P                  VV(4       K  	  EK8  	  V P                  P                  P                  '       dr   VP                  '       d`   V	'       g%   VP                  '       d   VP
                  '       g4   VP
                  '       d"   V P                  V P                  WR4      4       V'       da   V* FZ  w  p1p2V2P2                  P
                  '       g   K$  V P                  V P                  V2P0                  V2P2                  R4      4       K\  	  VV8w  dd   V'       d\   V P                  VP                  P                  VP                  .RR7      pV P                  V P                  WVR,          4      4       V$'       dd   V Pe                  WVRR7      w  p3p(V Pt                  RV Pw                  VP                  P                  4      RV3/,          pV P                  VV(4       V P                  P                  P                  '       d   V P                  P                  4        R# R# u upi u upi u upi )z3Perform a "physical" (non-ManyToMany) field update.r   )ignoreTr  rX  z!) of foreign key constraints for .F)r   r   rU  z) of unique constraints for r   )r,  type_rU  )rt   rU  z) of check constraints for rs   r  Nr   r}   r  r   r   r  r   r   rx   _fk_checkrM  rt   )IsetrF   rI   r   r?   r   r  r\  r   r_  r`  r)   r   addrU   r  r   _field_became_primary_keyr   r   _delete_unique_sqlr   r   r>   related_modelr   db_indexr[  r   rM  _delete_index_sqlr  _delete_check_sql_rename_field_sqlrP   r   r   rename_column_referencesr   r  r   _alter_column_type_sqlrg   r   r   r   "_alter_column_database_default_sqlr   r   r   r  _alter_column_null_sqlr  supports_combined_altersrh   r=   r   r   r  rp   r   sql_update_with_default_delete_primary_key_unique_should_be_addedr   rO  _create_primary_key_sqlr   r   _create_index_name_create_check_sqlr  r  )4rL   r.   r6   r<   r  r  r  r  r  fks_droppedr  r  r{   rc  re  constraint_nameold_collationnew_collationdrop_foreign_keys_old_relrB   rel_fk_namesr,  rd  index_names
index_nameold_db_checknew_db_checkrZ   actionsnull_actionspost_actionsold_type_suffixnew_type_suffixfragmentother_actionsneeds_database_defaultold_defaultnew_defaultfour_way_default_alterationr]   r   rels_to_updaterA   rel_db_paramsrel_typerel_collationold_rel_db_paramsold_rel_collationr  relr  s4   &&&&&&&&&                                           r   r  %BaseDatabaseSchemaEditor._alter_field  s    eOO$$:::&&&'''--$~ .   --(()t . H #h-1,  H,,!((	  $!1!1 34T00@A $    D$B$B9$X$X 38++2I2I%2IJ2I " %  $55!!"!-  6   #./14  ,-,,!((	  $4T44ULM $4 &))+6%))+6OO$$:: M M&&@@9+@+@ ; ;$$M :)9)9M M
 &KKM],J 	  &>i%S!'#55))GMM,@,@+At  6    ,GLL!4!4W5J5JG!TU  ,	 &T$ $$$'''9+;+;+; 9>8K8KL8Ku

8KL 00!!"ll( 1 K *
 T33E:FG	 * ++IE++IE<'L27++2I2I%2IJ2I " %  $55!!"-	  6   #./14  ,-,,!((	  $4T33EKL $4 y///LL&&KK(() ((c9--00,,i.>.>	@P@P ) #22doo2N#22doo2N  /1-((:::((I,@,@@ '+&A&A)}m'#Hm NN8$.##%%,,..''9+?+??;;EiX %%''NN77id 8  "'>>>)...9Q9Q9S9S00;K00;K..y99;.+)-&225YO >>Y^^+225YOH##H- !!#AAy'?'?'A'6 '6~~44inn"4 	$ ll. <'''@@@W#CM2V IIcNE%.,ABC&V))1E1E!F!3
   ' + //11"&K)]F*.*=*=i*H'K001E1E!F $//)2B2B"C!;  $0KCLL--#T__U[[5I5I%J%s
  $0 +VS&)  ,    )>)>)>$$U3''	==LL00DE ###y'7'7'7"""$$$LL//k/JK !!":9"PQ)))??LL55eGH!!":9"PQ !/GW#MM774??7SM$V,H)--k:M ' ; ;t ; W 1 5 5k B&*&A&A%%!'#Hm LL%%T__W-B-B-H-H-Q-QRx{
   -VS&)  -- !/4 OO$$:::&&&9#9#9#9AXAXAX'''LL##E6VW (399***LL++C,=,=syy%P ) <'L"55$$y'7'7&8 6 O LL&&u}W?UV
 ""&"@"@)$ #A #K '')=)=>;+ C LLf%??##CCCOO!!# DI
%v  M&%s   <|*|/:|4c                `   V P                   P                  P                  '       d   VP                  '       d   R# VP	                  V P                   R7      pVP
                  '       d   V P                  MV P                  pVRV P                  VP                  4      RVR,          /,          . 3# )z
Hook to specialize column null alteration.

Return a (sql, params) fragment to set a column to null or non-null
as required by new_field, or None if no changes are required.
Nrs   r   r   )
rF   rI   r   r   r   r   sql_alter_column_nullsql_alter_column_not_nullrp   r   )rL   r.   r6   r<   r  rZ   s   &&&&  r   r  /BaseDatabaseSchemaEditor._alter_column_null_sql  s     OO$$FFF/// %33t3OM >>> **33  dooi.>.>?M&1
  r!   c                   V P                  V4      pV P                  V4      pV.pV'       d   . pM9V P                  P                  P                  '       d   V P                  V4      p. pVP                  V P                  R7      pV'       d-   VP                  '       d   V P                  p	MV P                  p	MV P                  p	V	RV P                  VP                  4      RVR,          RV/,          V3# )z
Hook to specialize column default alteration.

Return a (sql, params) fragment to add or drop (depending on the drop
argument) a default to new_field's column.
rs   r   r   r  )r   r   rF   rI   r   r   r   r    sql_alter_column_no_default_nullsql_alter_column_no_defaultsql_alter_column_defaultrp   r   )
rL   r.   r6   r<   r  r  r  r]   r  rZ   s
   &&&&&     r   r  2BaseDatabaseSchemaEditor._alter_column_default_sql7  s     ,,Y7**95F__%%??? **;7GF!//4??/K~~~;;66//C$//)*:*:;f-7 
 	
r!   c                   V'       d   V P                   pRp. pMV P                  pV P                  V4      w  rgVP                  V P                  R7      pVRV P                  VP                  4      RVR,          RV/,          V3# )z
Hook to specialize column database default alteration.

Return a (sql, params) fragment to add or drop (depending on the drop
argument) a default to new_field's column.
r`   rs   r   r   r  )r  r  r   r   rF   rp   r   )	rL   r.   r6   r<   r  rZ   r   r]   r  s	   &&&&&    r   r  ;BaseDatabaseSchemaEditor._alter_column_database_default_sql]  s     22CKF//C"&"5"5i"@K!//4??/K$//)*:*:;f-; 
 	
r!   c           	     V   . pV P                  WeVP                  P                  4      ;p'       d   RV 2pMRpRp	V P                  P                  P
                  '       d   VP                  '       g   VP                  VP                  8w  d9   V P                  WWCP                  4      w  rV
'       d   VP                  W34       VP                  '       d   V P                  VP                  4      p	V P                  RV P                  VP                  4      RVRVRV	/,          . 3V3# )a\  
Hook to specialize column type alteration for different backends,
for cases when a creation type is different to an alteration type
(e.g. SERIAL in PostgreSQL, PostGIS fields).

Return a 2-tuple of: an SQL fragment of (sql, params) to insert into
an ALTER TABLE statement and a list of extra (sql, params) tuples to
run once the field is altered.
ru   r`   r   r   r   rt  )r   r)   r   rF   rI   r  r   r   r  rg   r   sql_alter_column_typerp   r   )rL   r.   r6   r<   r  r  r  r  collate_sqlcomment_sqlrZ   r]   s   &&&&&&&     r   r  /BaseDatabaseSchemaEditor._alter_column_type_sqly  s&    ++%++*>*>
 
; 
 k]+KK??##555i>T>T>T##y';';; #<<h0D0D !((#7###"//	0D0DE **dooi.>.>?H{	 	 
 	
r!   c           	         V P                   R V P                  VP                  P                  4      RV P                  VP                  4      RV P                  V4      /,          . 3# )r}   r   rt  )sql_alter_column_commentrp   r)   r   r   r   )rL   r.   r<   r  new_db_comments   &&&&&r   r  2BaseDatabaseSchemaEditor._alter_column_comment_sql  s`    )))=)=>$//)*:*:;4,,^< 
 	
r!   c                8    T P                  T;'       g    R 4      # r`   r   )rL   rt  s   &&r   r   %BaseDatabaseSchemaEditor._comment_sql  s    2..r!   c                   VP                   P                  P                  P                  VP                   P                  P                  P                  8w  dx   V P	                  VP                   P                  VP                   P                  P                  P                  VP                   P                  P                  P                  4       V P                  VP                   P                  VP                   P                  P                  P                  VP                  4       4      VP                   P                  P                  P                  VP                  4       4      4       V P                  VP                   P                  VP                   P                  P                  P                  VP                  4       4      VP                   P                  P                  P                  VP                  4       4      4       R# )z*Alter M2Ms to repoint their to= endpoints.N)	r?   r  r)   r   rq  r  r   m2m_reverse_field_namem2m_field_name)rL   r.   r6   r<   r  s   &&&&&r   r  ,BaseDatabaseSchemaEditor._alter_many_to_many  s    ""**0099%%--33<<= &&..&&..44==&&..44== 	""** ""**00::002 ""**00::002	
 	""** ""**00::9;S;S;UV""**00::9;S;S;UV	
r!   r`   c                :   \        V4      w  rA\        V.VO5R^/ : V: 2pV P                  P                  P	                  4       ;'       g    ^pV: RRP                  V4      : RV: 2p\        V4      V8:  d   V# \        V4      V^,          8  d   VRV^,           pV\        V4      ,
          ^,          ^,
          pVRV : RRP                  V4      RV : RV: 2pV^ ,          R8X  g   V^ ,          P                  4       '       d   RVRR ,          pV# )z
Generate a unique name for an index/unique constraint.

The name is divided into 3 parts: the table name, the column names,
and a unique digest and suffix.
lengthr  NzD%s)r   r   rF   ro   max_name_lengthr   r_  isdigit)	rL   
table_namecolumn_namesrM  r  hash_suffix_part
max_lengthr  other_lengths	   &&&&     r   r  +BaseDatabaseSchemaEditor._create_index_name  s    )4=l=1=
 __((88:AAc
#-sxx/EGWX
z?j( :>1/0A*/B"S)9%::q@1D}%HH\"=L1

 a=C:a=#8#8#:#:CR0Jr!   c                   Vf   \        V4      ^8X  d.   V^ ,          P                  '       d   V^ ,          P                  pMY\        P                  '       d   \        P                  pM2VP                  P                  '       d   VP                  P                  pVe-   RV P
                  P                  P                  V4      ,           # R# )Nru   r`   )r_  r   r   DEFAULT_INDEX_TABLESPACEr)   rF   ro   r   )rL   r.   r   r   s   &&&&r   _get_index_tablespace_sql2BaseDatabaseSchemaEditor._get_index_tablespace_sql  s     6{aF1I$;$;$; &q	 7 7222 ( A A*** % 9 9$,,;;MJJJr!   c                (    V'       d
   R V,           # R# )z WHERE r`   r   )rL   	conditions   &&r   _index_condition_sql-BaseDatabaseSchemaEditor._index_condition_sql  s    y((r!   c                    V'       d'   V P                   P                  P                  '       g   R # \        R\	        VP
                  P                  W P                  4      R7      # )r`   z INCLUDE (%(columns)s))r   )rF   rI   supports_covering_indexesr   r   r)   r   rp   )rL   r.   r   s   &&&r   _index_include_sql+BaseDatabaseSchemaEditor._index_include_sql  sE    doo66PPP$EKK00'??K
 	
r!   r   r   rM  usingr   col_suffixesrZ   	opclassesr  includeexpressionsc               P  a a T;'       g    . pT;'       g    . p\        VRR7      P                  S P                  R7      pS P                  WVR7      pV Uu. uF  qP                  NK  	  ppT;'       g    S P
                  pVP                  P                  pVV 3R lp\        T\        VS P                  4      \        VVVV4      TV'       d   S P                  VVWy4      M\        VWS P                  4      VS P                  V
4      S P!                  W4      R7      # u upi )z
Return the SQL statement to create the index for one or several fields
or expressions. `sql` can be specified if the syntax differs from the
standard (GIS indexes, ...).
F
alias_colsrs   )r   c                  R   < Sf   SP                   ! V / VB oSP                  S4      # r2   )r  rp   )argskwargsr   rL   s   *,r   create_index_nameEBaseDatabaseSchemaEditor._create_index_sql.<locals>.create_index_name0  s,    |..????4((r!   )r}   r   r"  r   r^   r  r%  )r   r   rF   r  r   sql_create_indexr)   r   r   r   rp   r
   _index_columnsr   rj   r  r   )rL   r.   r   r   rM  r"  r   r#  rZ   r$  r  r%  r&  r   r   r   r   r/  r}   r-  s   f&$d$$$$$$$$$       r   rO  *BaseDatabaseSchemaEditor._create_index_sql  s   * 2!''R51>> ? 
 77 8 
 .44VE<<V477$"7"7$$	) t/5'63DE  ##E7LL t?O?OP //	:++E;
 	
 5s   D#c                   \        T;'       g    V P                  \        VP                  P                  V P
                  4      V P                  V4      R 7      pVP                  R,          P                  pVP                  R,          p\        V P                  4       FO  p\        V\         4      '       g   K  VP                  WV4      '       g   K4  V P                  P                  V4       KQ  	  V# )r}   r   r}   r   )r   rN  r   r)   r   rp   partsr}   r#  rP   r   references_indexr%  )rL   r.   r   rZ   r   r  r  s   &&&&   r   r  *BaseDatabaseSchemaEditor._delete_index_sqlE  s    ((4((,,doo>&
	 __W-33
__V,
))*C#y))c.B.B/ / !!((-	 + r!   c                    \        V P                  \        VP                  P                  V P
                  4      V P                  V4      V P                  V4      R 7      # ))r}   old_namenew_name)r   sql_rename_indexr   r)   r   rp   )rL   r.   r8  r9  s   &&&&r   r5  *BaseDatabaseSchemaEditor._rename_index_sqlW  sH    !!,,doo>__X.__X.	
 	
r!   c                2    \        WV P                  VR 7      # ))r#  )r   rp   )rL   r}   r   r#  r$  s   &&&&&r   r0  'BaseDatabaseSchemaEditor._index_columns_  s    ut\RRr!   c                   VP                   P                  '       d9   VP                   P                  '       g   VP                   P                  '       d   . # . pVP                   P                   F#  pVP                  V P                  W4      4       K%  	  VP                   P                   F]  pVP                  '       d)   V P                  P                  P                  '       g   K=  VP                  VP                  W4      4       K_  	  V# )zb
Return a list of all index SQL statements (field indexes, Meta.indexes)
for the specified model.
)r)   managedproxyswappedr   r   r  r[  r)  rF   rI   r*  rg   r   )rL   r.   outputr   r,  s   &&   r   r  +BaseDatabaseSchemaEditor._model_indexes_sqlb  s    
 {{"""ekk&7&7&75;;;N;N;NI[[--EMM$11%?@ . [[((E...??++GGGe..u;< ) r!   c                |    . pV P                  W4      '       d#   VP                  V P                  W.R7      4       V# )zD
Return a list of all index SQL statements for the specified field.
r  )_field_should_be_indexedrg   rO  )rL   r.   r   rB  s   &&& r   r  +BaseDatabaseSchemaEditor._field_indexes_sqlu  s;     ((66MM$00w0GHr!   c                x   VP                   '       g9   VP                  '       g'   VP                   '       g   VP                  '       g   R # T;'       g    \        4       pVP                  4       w  rErgVP                  4       w  rHrVP	                  VP
                  4       F  pVP                  VR4       K  	  VP	                  VP
                  4       F  pV
P                  VR4       K  	  VP                  '       g   VP                  '       d   VP                  '       d|   VP                  P                  P                  P                  VP                  P                  P                  P                  8X  d%   VP                  RR4       V
P                  RR4       VP                  R4      '       d_   V
P                  R4      '       dH   V P                  V4      V P                  V4      8X  d#   VP                  R4       V
P                  R4       VP                   '       dN   VP                   '       d<   V P                  VP                  4      V P                  VP                  4      8w  d   R# VP                  '       d0   VP                  '       d   VP                  VP                  8w  d   R# WVV3WV
38g  # )FNtor   T)concreter   r  deconstructunionnon_db_attrspopr?   r.   r)   r   r   r   rp   r   r   )rL   r6   r<   r  r  old_pathold_args
old_kwargsnew_pathnew_args
new_kwargsattrs   &&&&        r   r  1BaseDatabaseSchemaEditor._field_should_be_altered~  s   ###y'='='=###y'='='=35,5,A,A,C)X,5,A,A,C)X LL!7!78DNN4& 9LL!7!78DNN4& 9 &&&&&&&&&&&,,22;;%%++11::; NN4&NN4& NN<((|,,##I.$2E2Ei2PPNN<(NN<("""!1!12dooiFVFV6WW"""&&&)..0J/H
3SSSr!   c                L    VP                   ;'       d    VP                  '       * # r2   )r  r   rL   r.   r   s   &&&r   rE  1BaseDatabaseSchemaEditor._field_should_be_indexed  s    ~~22ell"22r!   c                L    VP                   '       * ;'       d    VP                   # r2   r   rL   r6   r<   s   &&&r   r  2BaseDatabaseSchemaEditor._field_became_primary_key  s    (((BBY-B-BBr!   c                    VP                   '       * ;'       d:    VP                  ;'       d&    VP                  '       * ;'       g    VP                   # r2   )r   r   r[  s   &&&r   r  0BaseDatabaseSchemaEditor._unique_should_be_added  sN    %%% @ @  @ @%%%>>)>)>	
r!   c           	         V P                   R V P                  V4      RV P                  VP                  4      RV P                  VP                  4      RV/,          # )r}   
old_column
new_columnr   )sql_rename_columnrp   r   )rL   r}   r6   r<   r  s   &&&&&r   r  *BaseDatabaseSchemaEditor._rename_field_sql  sU    %%T__U+$//)*:*:;$//)*:*:;H	)
 
 	
r!   c           
        \        VP                  P                  V P                  4      pV P	                  WV4      p\        VP                  P                  VP                  .V P                  4      p\        VP                  P                  P                  P                  V P                  4      p\        VP                  P                  P                  P                  VP                  P                  .V P                  4      pV P                  P                  P                  4       p	\        V P                  VVVVVV	R 7      # ))r}   r   r   rv   rw   r  )r   r)   r   rp   r  r   r   target_fieldr.   rF   ro   r  r   sql_create_fk)
rL   r.   r   rM  r}   r   r   rv   rw   r  s
   &&&&      r   r   'BaseDatabaseSchemaEditor._create_fk_sql  s    ekk**DOO<''f=--~tO++1177@@$//R$$**33&&'OO
	
 __((779
!
 	
r!   c                  a  V 3R  lp\        VP                  P                  VP                  .\	        VP
                  P                  P                  P                  4      ^,          VP
                  P                  .VV4      # )c                  F   < SP                  SP                  ! V / VB 4      # r2   rp   r  r+  r,  rL   s   *,r   create_fk_nameDBaseDatabaseSchemaEditor._fk_constraint_name.<locals>.create_fk_name  s"    ??4#:#:D#KF#KLLr!   )r	   r)   r   r   r   re  r.   )rL   r.   r   rM  rl  s   f&&& r   r  ,BaseDatabaseSchemaEditor._fk_constraint_name  sk    	M KK  \\NU//55;;DDEaH&&'
 	
r!   c                :    V P                  V P                  W4      # r2   )ra  sql_delete_fkrL   r.   r   s   &&&r   r  'BaseDatabaseSchemaEditor._delete_fk_sql      **4+=+=uKKr!   c                n    Vf   R# V\         P                  8X  d   R# V\         P                  8X  d   R# R # )Nr`   z DEFERRABLE INITIALLY DEFERREDz DEFERRABLE INITIALLY IMMEDIATE)r   DEFERRED	IMMEDIATE)rL   r  s   &&r   _deferrable_constraint_sql3BaseDatabaseSchemaEditor._deferrable_constraint_sql  s2    ,,,3---4 .r!   c                &    VR J d   R# VRJ d   R# R# )Fz NULLS NOT DISTINCTTz NULLS DISTINCTr`   r   )rL   nulls_distincts   &&r    _unique_index_nulls_distinct_sql9BaseDatabaseSchemaEditor._unique_index_nulls_distinct_sql  s    U"(t#$r!   c                   V'       * ;'       g)    V P                   P                  P                  ;'       d    V'       * ;'       g)    V P                   P                  P                  ;'       d    V'       * ;'       g)    V P                   P                  P                  ;'       dd    V'       * ;'       g)    V P                   P                  P
                  ;'       d-    VR J ;'       g!    V P                   P                  P                  # r2   )rF   rI   supports_partial_indexes&supports_deferrable_unique_constraintsr  r*  *supports_nulls_distinct_unique_constraints)rL   r  r  r%  r&  rz  s   &&&&&&r   _unique_supported*BaseDatabaseSchemaEditor._unique_supported  s     ]OOdoo66OO   S S??++RR 
 RR 8 8 R R   WW4??#;#;#W#W  $& W W??++VV	
r!   c
                   V P                  VVVVV	R 7      '       g   R# V'       g   V'       g   V'       g   V'       g   V	e?   V P                  VVVVVVVV	R7      p
V
'       d   V P                  P                  V
4       R# V P                  RRP                  V Uu. uF  qP                  VP                  4      NK  	  up4      RV P                  V4      /,          pV P                  RV P                  V4      RV/,          # u upi )r  r  r%  r&  rz  N)r   r  r%  r$  r&  rz  r   r   r  r   r{   )
r  r   rP   rg   sql_unique_constraintr   rp   r   rw  sql_constraint)rL   r.   r   r   r  r  r%  r$  r&  rz  rZ   r   r{   s   &&&&&&&&&&   r   _unique_sql$BaseDatabaseSchemaEditor._unique_sql  s    %%!#) & 
 
  ) ))##'- * 	C !!((-//tyyV!TVE//%,,"?V!TU$99*E3
 

 ""DOOD)*&
 
 	
 "Us   #Dc
                   V P                  VVVVV	R 7      '       g   R# \        VRR7      P                  V P                  R7      p
VP                  P
                  pV Uu. uF  qP                  NK  	  ppVf   V P                  WRR7      pMV P                  V4      pV'       g   V'       g   V'       g	   V'       d   V P                  pMV P                  pV'       d   V P                  WR	VR7      pM\        WWP                  4      p\        V\        WP                  4      VVV P!                  V4      V P#                  V4      V P%                  W4      V P'                  V	4      R7      # u upi )
r  NFr(  rs   TrV  )r#  r$  )r}   r   r   r  r  r%  rz  r   )r  r   r   rF   r)   r   r   r^  rp   sql_create_unique_indexsql_create_uniquer0  r   rj   r   r   r  rw  r   r{  )rL   r.   r   r   r  r  r%  r$  r&  rz  r   r}   r   r   rZ   s   &&&&&&&&&&     r   r   +BaseDatabaseSchemaEditor._create_unique_sqlD  sS    %%!#) & 
 
 51>> ? 
 $$-34VE<<V4<//d/KD??4(D9..C((C))R9 * G "%h@P@PQG///	:66zB++E;@@P	
 		
 5s    E-c                T   a  V'       d   V 3R  lpMS P                   p\        WRV4      # )c                  F   < SP                  SP                  ! V / VB 4      # r2   rj  rk  s   *,r   create_unique_nameLBaseDatabaseSchemaEditor._unique_constraint_name.<locals>.create_unique_namez  s"    t'>'>'O'OPPr!   _uniq)r  r
   )rL   r}   r   rW  r  s   f&&& r   r^  0BaseDatabaseSchemaEditor._unique_constraint_namew  s*    Q "&!8!82DEEr!   c	                    V P                  VVVVVR 7      '       g   R# V'       g   V'       g   V'       g	   V'       d   V P                  p	MV P                  p	V P                  WV4      # )r  N)r  rN  rD  ra  )
rL   r.   r   r  r  r%  r$  r&  rz  rZ   s
   &&&&&&&&& r   r  +BaseDatabaseSchemaEditor._delete_unique_sql  sb     %%!#) & 
 
 9''C((C**3t<<r!   c                t    V P                   R V P                  V4      RV P                  RV/,          /,          # )r   r{   rt   )r  rp   r   )rL   r   rt   s   &&&r   
_check_sql#BaseDatabaseSchemaEditor._check_sql  s=    ""DOOD)$33w6FF&
 
 	
r!   c                    V P                   P                  P                  '       g   R # \        V P                  \        VP                  P                  V P                  4      V P                  V4      VR7      # )N)r}   r   rt   )	rF   rI    supports_table_check_constraintsr   sql_create_checkr   r)   r   rp   )rL   r.   r   rt   s   &&&&r   r  *BaseDatabaseSchemaEditor._create_check_sql  sX    ''HHH!!,,doo>&	
 	
r!   c                    V P                   P                  P                  '       g   R # V P                  V P                  W4      # r2   )rF   rI   r  ra  sql_delete_checkrq  s   &&&r   r  *BaseDatabaseSchemaEditor._delete_check_sql  s4    ''HHH**4+@+@%NNr!   c                    \        V\        VP                  P                  V P                  4      V P	                  V4      R 7      # )r3  )r   r   r)   r   rp   )rL   templater.   r   s   &&&&r   ra  /BaseDatabaseSchemaEditor._delete_constraint_sql  s6    ,,doo>&
 	
r!   c
           
        Ve   V U
u. uF  p
V P                   P                  P                  '       dQ   V P                   P                  P	                  \        WP                   P                  P                  4       4      4      M$V P                   P                  P	                  V
4      NK  	  pp
V P                   P                  4       ;_uu_ 4       pV P                   P                  P                  WP                  P                  4      pRRR4       . pXP                  4        F  w  rVe   W.R,          8X  g   K  Ve   VR,          V8w  d   K,  Ve   VR,          V8w  d   K@  Ve   VR,          V8w  d   KT  Ve   VR,          V8w  d   Kh  Ve   VR,          '       g   K}  Ve   VR,          V8w  d   K  V	'       d	   W9  g   K  VP                  V
4       K  	  V# u up
i   + '       g   i     L; i)	z@Return all constraint names matching the columns and conditions.Nr   r   r   r,  rt   r  r   )rF   rI   truncates_namesintrospectionidentifier_converterr   ro   r  rk   get_constraintsr)   r   itemsrg   )rL   r.   r  r   r   r,  r  rt   r  rU  r   rk   r   resultinfodicts   &&&&&&&&&&     r   r\  *BaseDatabaseSchemaEditor._constraint_names  s    # )	 )D //??? OO11FF%dOO,?,?,O,O,QR 66KKDQ	R )  	 __##%%//77GG,,K & )//1ND#|	7J'J%(8*<*F*x/F+/U$'):e)C$'):e)C*8M3J3J$&)9U)B$"5MM$' 2  ?	 &%s   *GA9G:G""G2	c                `   a  S P                   R RP                  V 3R lV 4       4      /,          # )r   r   c              3   F   <"   T F  pSP                  V4      x  K  	  R # 5ir2   rp   )r4   r   rL   s   & r   r7   >BaseDatabaseSchemaEditor._pk_constraint_sql.<locals>.<genexpr>  s      OwV!8!8wr   )sql_pk_constraintr   )rL   r   s   f&r   r   +BaseDatabaseSchemaEditor._pk_constraint_sql  s/    %%tyy Ow OO)
 
 	
r!   c                   V P                  VR R7      pV'       dA   \        V4      ^8w  d1   \        R\        V4      : RVP                  P                  : 24      hV F#  pV P                  V P                  W4      4       K%  	  R# )TrZ  rX  z) of PK constraints for N)r\  r_  r`  r)   r   rU   _delete_primary_key_sql)rL   r.   r  re  r  s   &&&  r   r  ,BaseDatabaseSchemaEditor._delete_primary_key  su    11%T1Jc*+q0 ()KK((   0OLL55eMN  0r!   c                l   \        V P                  \        VP                  P                  V P
                  4      V P                  V P                  VP                  P                  VP                  .R R7      4      \        VP                  P                  VP                  .V P
                  4      R7      # )_pkr  )r}   r   r   )	r   sql_create_pkr   r)   r   rp   r  r   r   rW  s   &&&r   r  0BaseDatabaseSchemaEditor._create_primary_key_sql  s    ,,doo>''KK((5<<. ( 
 EKK005<<.$//R	
 		
r!   c                :    V P                  V P                  W4      # r2   )ra  sql_delete_pkrq  s   &&&r   r  0BaseDatabaseSchemaEditor._delete_primary_key_sql  rs  r!   c                F    V'       d   R V P                  V4      ,           # R# )zCOLLATE r`   r  )rL   r   r  r  s   &&&&r   r   %BaseDatabaseSchemaEditor._collate_sql  s    :CzDOOI66KKr!   c                    V P                   R V P                  V4      RRP                  V4      /,          pV P                  V4       R# )	procedureparam_types,N)sql_delete_procedurerp   r   rU   )rL   procedure_namer  rZ   s   &&& r   remove_procedure)BaseDatabaseSchemaEditor.remove_procedure
  sA    ''8388K0+
 
 	Sr!   )r   rK   rG   rH   rF   rP   )FTr   )r   )Fr  r2   )NNNNN)NNNNNN)NNNNNNN)T)NNNNNNNNr   ){__name__
__module____qualname____firstlineno____doc__r   rm  r|  r"  r  r  r  r  r  r  r  r  r  rb  r  r  r   sql_delete_constraintr  r  r  r  r  rD  rf  r   r  rp  r/  r  r:  rN  r  r  r  ru  r  rM   rR   rV   rU   rp   r   r   r   r   r   r   r   r   r   staticmethodr  r   rj   r  r!  r-  r1  r8  r<  r?  rI  rR  rC  rq  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r   rO  r  r5  r0  r  r  r  rE  r  r  r  r   r  r  rw  r{  r  r  r   r^  r  r  r  r  ra  r\  r   r  r  r  r   r  __static_attributes____classdictcell__)__classdict__s   @r   rD   rD   N   sB     AJV5T:PC FP"H'B$FN  	Q  A.L9N3X,	?  .	@   "&)M	9 
	B  I, 	R  *M9IVUA,>4aJA6F
6
)&S  2W$!>F.*	A4-+A*V* SDH&	
V$p.@Q
f	q$f:$
L
8,
\	
/
B@


4
 	4

 4
 4
 4
 4
 4
 4
 4
 4
 4
 4
l$
S&/Tb3C


*
L5
02
h1
f	F=2

O

-^

O

LL r!   rD   )&loggingr+   r   	itertoolsr   django.confr   django.core.exceptionsr   !django.db.backends.ddl_referencesr   r   r	   r
   r   r   django.db.backends.utilsr   r   r   django.db.modelsr   r   !django.db.models.fields.compositer   django.db.models.sqlr   django.db.transactionr   r   django.utilsr   	getLoggerrc   r    r/   r>   rD   r   r!   r   <module>r     se          -  S R . A & D !			6	71 

.A Ar!   