
    VhC                     n    d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
mZ d dlmZmZ  G d de      Zy	)
    )import_module)apps)BaseCommandCommandError)no_style)emit_post_migrate_signal	sql_flush)DEFAULT_DB_ALIASconnectionsc                        e Zd ZdZdZd Zd Zy)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                 |    |j                  ddddd       |j                  dt        t        t              d	       y )
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.)defaultchoicesr   )add_argumentr
   tupler   )selfparsers     U/home/dcms/DCMS/lib/python3.12/site-packages/django/core/management/commands/flush.pyadd_argumentszCommand.add_arguments   sJ     M 	 	
 	$+&U	 	 	
    c                    |d   }t         |   }|d   }|d   }|j                  dd      }|j                  dd      }|j                  dd      }t               | _        t	        j
                         D ]  }		 t        d	|	j                          t        | j                  |||
      }
|rt        d|j                  d   z        }nd}|dk(  r0	 |j                  j                  |
       |
r|st!        |||       y y y | j"                  j%                  d       y # t        $ r Y w xY w# t        $ r"}t        d|j                  d   d      |d }~ww xY w)Ndatabase	verbosityr   r   Tr   Fr   z.management)r   r   zYou 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yesz	Database a#   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.zFlush 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excs                r   handlezCommand.handle    s}   :& *
K(	m,!++&7>OU;&{{+A5IZ
 ..0 	JmZ__=	 JJ+'	
 3 **623G Ge00:  4 )KJ !5x
 KK01Y  4  	" "//7: 	s*   6DD' 	D$#D$'	E0EEN)__name__
__module____qualname__r   stealth_optionsr   r7    r   r   r   r   
   s    	@ 	 SO
=2r   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   <module>rC      s%    #  A 1 J 3S2k S2r   