File: //usr/lib/python3/dist-packages/django/core/management/commands/__pycache__/flush.cpython-310.pyc
o
�a�
� @ sh d dl mZ d dlmZ d dlmZmZ d dlmZ d dl m
Z
mZ d dlm
Z
mZ G dd� de�Zd S )
� )�
import_module)�apps)�BaseCommand�CommandError)�no_style)�emit_post_migrate_signal� sql_flush)�DEFAULT_DB_ALIAS�connectionsc @ s$ e Zd ZdZdZdd� Zdd� ZdS )�CommandzuRemoves ALL DATA from the database, including data added during migrations. Does not achieve a "fresh install" state.)�reset_sequences�
allow_cascade�inhibit_post_migratec C s( |j dddddd� |j dtdd � d S )
Nz --noinputz
--no-input�store_false�interactivez:Tells Django to NOT prompt the user for input of any kind.)�action�dest�helpz
--databasezBNominates a database to flush. Defaults to the "default" database.)�defaultr )�add_argumentr )�self�parser� r �G/usr/lib/python3/dist-packages/django/core/management/commands/flush.py�
add_arguments s �
�zCommand.add_argumentsc
K s" |d }t | }|d }|d }|�dd�}|�dd�}|�dd�}t� | _t�� D ]} ztd | j� W q* ty= Y q*w t | j|||d
�}
|rSt
d|jd �}nd
}|d
kr�z|j�
|
� W n tyx } ztd|jd f �|�d }~ww |
r�|s�t|||� d S d S d S | j�d� d S )N�database� verbosityr r Tr
Fr z.management)r r
z�You have requested a flush of the database.
This will IRREVERSIBLY DESTROY all data currently in the "%s" database,
and return each table to an empty state.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: �NAME�yesa. Database %s couldn't be flushed. Possible reasons:
* The database isn't running or isn't configured correctly.
* At least one of the expected database tables doesn't exist.
* The SQL was invalid.
Hint: Look at the output of 'django-admin sqlflush'. That's the SQL this command wasn't able to run.zFlush cancelled.)r
�getr �styler �get_app_configsr �name�ImportErrorr �input�
settings_dict�ops�execute_sql_flush� Exceptionr r �stdout�write)
r �optionsr �
connectionr r r r
r �
app_config�sql_list�confirm�excr r r �handle sR ������ ���
�zCommand.handleN)�__name__�
__module__�__qualname__r �stealth_optionsr r1 r r r r r
s �
r N)� importlibr �django.appsr �django.core.management.baser r �django.core.management.colorr �django.core.management.sqlr r � django.dbr r
r r r r r �<module> s