
    kh<                     z    d Z ddlZddlmZmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ  G d	 d
e          ZdS )z
Recreates the public schema for current database (PostgreSQL only).
Useful for Docker environments where you need to reset database
schema while there are active connections.
    N)BaseCommandCommandError)DEFAULT_DB_ALIAS)connections)settings)POSTGRESQL_ENGINES)RemovedInNextVersionWarningc                   ,     e Zd ZdZdZ fdZd Z xZS )Commandz&`reset_schema` command implementation.z-Recreates the public schema for this project.c                 @   t                                          |           |                    dddddd           |                    dd	d
dt          d           |                    dt          dt          z             |                    ddd
ddd           d S )Nz	--noinputz
--no-inputstore_falseinteractiveTz:Tells Django to NOT prompt the user for input of any kind.)actiondestdefaulthelpz-Rz--routerstorerouterzBUse this router-database instead of the one defined in settings.pyz
--databasez>Nominates a database to run command for. Defaults to the "%s".)r   r   z-Sz--schemaschemapublicz$Drop this schema instead of "public")superadd_argumentsadd_argumentr   )selfparser	__class__s     i/var/www/histauto/venv/lib/python3.11/site-packages/django_extensions/management/commands/reset_schema.pyr   zCommand.add_arguments   s    f%%% M 	 	
 	
 	
 	$U 	 	
 	
 	
 	$Q 	 	
 	
 	
 	7 	 	
 	
 	
 	
 	
    c                    |d         }|d         t           k    r$t          j        dt          d           |d         }t          j                            |          }|t          d|z            |                    d          }|t          vrt          d          |d	         }|d
         }|d         r$t          d
                    ||                    }nd}|dk    rt          d           d S t          |                                         5 }	|	                    d
                    |                     |	                    d
                    |                     d d d            d S # 1 swxY w Y   d S )Ndatabaser   z2--router is deprecated. You should use --database.   )
stacklevelzUnknown database %sENGINEz8This command can be used only with PostgreSQL databases.NAMEr   r   z
You have requested a database schema reset.
This will IRREVERSIBLY DESTROY ALL data
in the "{}" schema of database "{}".
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yeszReset cancelled.zDROP SCHEMA {} CASCADEzCREATE SCHEMA {})r   warningswarnr	   r   	DATABASESgetr   r   inputformatprintr   cursorexecute)
r   argsoptionsr    dbinfoenginedatabase_namer   confirmr-   s
             r   handlezCommand.handle9   s   :&8 000MD+   
 x(H#''11>4x?@@@H%%+++J   v"=! 	/ 06vfm/L/L GG Ge$%%%F"))++ 	>vNN3::6BBCCCNN-44V<<===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   AE00E47E4)__name__
__module____qualname____doc__r   r   r5   __classcell__)r   s   @r   r   r      sS        00:D
 
 
 
 
B+> +> +> +> +> +> +>r   r   )r9   r&   django.core.managementr   r   	django.dbr   r   django.confr   django_extensions.settingsr   #django_extensions.utils.deprecationr	   r    r   r   <module>rA      s      < < < < < < < < & & & & & & ! ! ! ! ! !             9 9 9 9 9 9 K K K K K KQ> Q> Q> Q> Q>k Q> Q> Q> Q> Q>r   