HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/django/core/management/commands/__pycache__/migrate.cpython-310.pyc
o

3�a�A�@s�ddlZddlZddlmZddlmZddlmZmZm	Z	ddl
mZmZddl
mZmZmZddlmZddlmZdd	lmZdd
lmZmZddlmZddlmZGd
d�de�ZdS)�N)�
import_module)�apps)�BaseCommand�CommandError�no_translations)�emit_post_migrate_signal�emit_pre_migrate_signal)�DEFAULT_DB_ALIAS�connections�router)�MigrationAutodetector)�MigrationExecutor)�AmbiguityError)�
ModelState�ProjectState)�module_has_submodule)�	Truncatorc@sFeZdZdZgZdd�Zedd��Zddd	�Zd
d�Z	e
dd
��ZdS)�CommandzMUpdates database schema. Manages both apps with migrations and those without.cCs�|jdddd�|jdddd�|jd	dd
d�|jddd
ddd�|jdtdd�|jdddd�|jdddd�|jdddd�|jdddd�|jddddd�dS)Nz
--skip-checks�
store_truezSkip system checks.)�action�help�	app_label�?z5App label of an application to synchronize the state.)�nargsr�migration_namezpDatabase state will be brought to the state after that migration. Use the name "zero" to unapply all migrations.z	--noinputz
--no-input�store_false�interactivez:Tells Django to NOT prompt the user for input of any kind.)r�destrz
--databasezHNominates a database to synchronize. Defaults to the "default" database.)�defaultrz--fakez5Mark migrations as run without actually running them.z--fake-initialz�Detect if tables already exist and fake-apply initial migrations if so. Make sure that the current database schema matches your initial migration before using this flag. Django will only check for an existing table name.z--planz=Shows a list of the migration actions that will be performed.z--run-syncdbz+Creates tables for apps without migrations.z--check�check_unappliedz;Exits with a non-zero status if unapplied migrations exist.)�add_argumentr	)�self�parser�r#�I/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py�
add_argumentssR���������
�zCommand.add_argumentsc!
s�|d}|ds|j|gd�|d|_|d|_t��D]}t|jd�r+td|j�qt	|}|�
�t||j�}|j
�|�|j
��}|rYd�d	d
�|��D��}td|��|d}	d
}
|dr�|d�zt���Wnty�}ztt|���d}~ww|	r��|j
jvr�td���n�|j
jvr�td���|dr�|dr�|d}|dkr��dfg}
n-z	|j
��|�}Wnty�td|�f��ty�td|�f��w�|jfg}
d}
n|dr�fdd�|j
j��D�}
n|j
j��}
|�|
�}|�o|d}|d�r[|j�d|jj �|�s|j�d�|D]1\}}|j�t|�|jj!�|j"D]}|�#||�\}}|�rB|jj$nd}|j�d||��q1�q|�rYt%�&d�dS|�rct%�&d�|d�ok|j
j'}	|jdk�r�|j�|j�!d��|	�r�|d�r�|j�|j� d���n|j�|j� d �d!�t(|j
j'���|
�r�|j�|j� d"�d!�t(d#d$�|
D����p�d%�n4|
d&ddu�r�|j�|j� d'�t|
d&d&��n|j�|j� d(�d)|
d&d|
d&d&f�|j)d
d*�}|j}t*|j|j|j+||d+�|	�r2|jdk�r|j�|j�!d,��|d�r*|�,|�g�n|�,||j
j'�|jdk�rB|j�|j�!d-��|�s�|jdk�r�|j�d.�t-|j
�.�t/�0t��}|j1|j
jd/�}|�r�|j�|j�2d0d!�d1d
�t(|�D����|j�|j�2d2��d}d}n|d3}|d4}|j3|
||�4�||d5�}|�5�|j}|�6��!g}|j7D]}|j8|j9f} |�:| �|j;| ��q�Wd�n	1�s�wY|�<d6d�|D��t=|j|j|j+||d+�dS)7N�database�skip_checks)�	databases�	verbosityr�
managementz.managementz; css&�|]\}}dd�|�|fVqdS)z%s in %s�, N)�join)�.0�app�namesr#r#r$�	<genexpr>es
��
�z!Command.handle.<locals>.<genexpr>z�Conflicting migrations detected; multiple leaf nodes in the migration graph: (%s).
To fix them run 'python manage.py makemigrations --merge'�
run_syncdbTrz8Can't use run_syncdb with app '%s' as it has migrations.z"App '%s' does not have migrations.r�zerozJMore than one migration matches '%s' in app '%s'. Please be more specific.z4Cannot find a migration matching '%s' from app '%s'.Fcsg|]
}|d�kr|�qS)rr#)r-�key�rr#r$�
<listcomp>�sz"Command.handle.<locals>.<listcomp>r�planzPlanned operations:z"  No planned migration operations.z    �zOperations to perform:z   Synchronize unmigrated app: %sz  Synchronize unmigrated apps: r+z  Apply all migrations: cSsh|]\}}|�qSr#r#)r-�a�nr#r#r$�	<setcomp>�sz!Command.handle.<locals>.<setcomp>z(none)rz  Unapply all migrations: z  Target specific migration: z%s, from %s)�with_applied_migrations)rr6z&Synchronizing apps without migrations:zRunning migrations:z  No migrations to apply.)�graphzl  Your models in app(s): %s have changes that are not yet reflected in a migration, and so won't be applied.css�|]}t|�VqdS�N)�repr)r-r.r#r#r$r0�s�zk  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.�fake�fake_initial)r6�stater?r@cSsg|]
}t�tj|���qSr#)r�
from_modelr�	get_model)r-�modelr#r#r$r5s�)>�checkr)rr�get_app_configsr�moduler�namer
�prepare_databaser
�migration_progress_callback�loader�check_consistent_history�detect_conflictsr,�itemsr�get_app_config�LookupError�str�
migrated_apps�get_migration_by_prefixr�KeyErrorr<�
leaf_nodes�migration_plan�stdout�write�style�
MIGRATE_LABEL�MIGRATE_HEADING�
operations�describe_operation�WARNING�sys�exit�unmigrated_apps�sorted�_create_project_stater�alias�	sync_appsr�
project_stater�	from_apps�changes�NOTICE�migrate�clone�clear_delayed_apps_cache�bulk_update�real_modelsr�
name_lower�append�unregister_model�render_multipler)!r!�args�optionsr&�
app_config�
connection�executor�	conflicts�name_strr1�target_app_labels_only�errr�targets�	migrationr6�exit_dry�	backwards�	operation�message�is_errorrY�pre_migrate_state�pre_migrate_apps�autodetectorrhr?r@�post_migrate_state�post_migrate_apps�
model_keys�model_state�	model_keyr#r4r$�handleGsJ

�

����������


�

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


��
�
�zCommand.handleNFcCs�|jdkr�|jdk}|dkr&|rt��|_|jjd|dd�|j��dS|dkrU|r5dt��|jnd}|rG|j�|j�d|��dS|j�|j�d	|��dS|d
krq|r`t��|_|jjd|dd�|j��dS|dkr�|r�dt��|jnd}|r�|j�|j�d|��dS|j�|j�d	|��dS|d
kr�|r�t��|_|jjddd�|j��dS|dkr�|r�dt��|jnd}|j�|j�d|��dSdSdS)Nr7�apply_startz  Applying %s...�)�ending�
apply_successz (%.3fs)z FAKEDz OK�
unapply_startz  Unapplying %s...�unapply_success�render_startz  Rendering model states...�render_successz DONE)	r)�time�	monotonic�startrWrX�flushrY�SUCCESS)r!rr}r?�compute_time�elapsedr#r#r$rJs@




�z#Command.migration_progress_callbackc
sJ����}�j�|��Wd�n1swY��fdd�t��D�}��fdd���fdd�|D�}|jdkrA|j�d	�����V}|�	�D]5\}}|D].}	|	j
���sYqP|jd
krj|j�d||	j
jf�|jdkry|j�d|	j
j
�|�|	�qPqJ|jdkr�|j�d
�Wd�dSWd�dS1s�wYdS)z;Run the old syncdb-style operation on a list of app_labels.Ncs8g|]}|jdur|j�vr|jtj|�jdd�f�qS)NF)�include_auto_created)�
models_module�labelr�get_migratable_modelsrd)r-ru)�
app_labelsrvr#r$r58s��z%Command.sync_apps.<locals>.<listcomp>cs6|j}�jj}||j��vp|jo||jjj��vSr=)�_meta�
introspection�identifier_converter�db_table�auto_created)rD�opts�	converter)rv�tablesr#r$�model_installedAs
�z*Command.sync_apps.<locals>.model_installedcs i|]\}}|tt�|���qSr#)�list�filter)r-�app_name�
model_list)r�r#r$�
<dictcomp>Is��z%Command.sync_apps.<locals>.<dictcomp>r7z  Creating tables...�z    Processing %s.%s modelz    Creating table %sz    Running deferred SQL...)�cursorr��table_namesrrFr)rWrX�
schema_editorrNr��can_migrate�object_namer��create_model)
r!rvr�r��
all_models�manifest�editorr�r�rDr#)r�rvr�r�r$re2s<
��	
�


�
�

�"�zCommand.sync_appscCs�d}d}t|d�r|r|jn|j}|r|jpdnd}nt|d�r)|r%|jn|j}nd}|r/d}|dur<t|��dd�}n|rBd}d	}|rHd
|}t|�}||�	�|�
d�|fS)z@Return a string that describes a migration operation for --plan.r�F�codeN�sqlzUndo �
�IRREVERSIBLETz -> �()�hasattr�reverse_coder��__doc__�reverse_sqlr�rQ�replacer�describe�chars)r�r�prefixr�r�r�	truncatedr#r#r$r]cs*
�
zCommand.describe_operation)NF)�__name__�
__module__�__qualname__r�requires_system_checksr%rr�rJre�staticmethodr]r#r#r#r$rs.

I"1r)r_r��	importlibr�django.appsr�django.core.management.baserrr�django.core.management.sqlrr�	django.dbr	r
r�!django.db.migrations.autodetectorr�django.db.migrations.executorr
�django.db.migrations.loaderr�django.db.migrations.staterr�django.utils.module_loadingr�django.utils.textrrr#r#r#r$�<module>s