o a @shddlmZddlmZddlmZmZddlmZddl m Z m Z ddl m Z mZGdddeZd S) ) import_module)apps) BaseCommand CommandError)no_style)emit_post_migrate_signal sql_flush)DEFAULT_DB_ALIAS connectionsc@s$eZdZdZdZddZddZdS)CommandzuRemoves ALL DATA from the database, including data added during migrations. Does not achieve a "fresh install" state.)reset_sequences allow_cascadeinhibit_post_migratecCs(|jdddddd|jdtdd dS) Nz --noinputz --no-input store_false interactivez:Tells Django to NOT prompt the user for input of any kind.)actiondesthelpz --databasezBNominates a database to flush. Defaults to the "default" database.)defaultr) add_argumentr )selfparserrG/usr/lib/python3/dist-packages/django/core/management/commands/flush.py add_argumentss zCommand.add_argumentsc Ks"|d}t|}|d}|d}|dd}|dd}|dd}t|_tD]} ztd | jWq*ty=Yq*wt |j|||d } |rSt d |j d } nd } | d krz|j | Wntyx} z td|j d f| d} ~ ww| r|st|||dSdSdS|jddS)Ndatabase verbosityrr Tr Frz .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: NAMEyesa.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 getrstylerget_app_configsrname ImportErrorrinput settings_dictopsexecute_sql_flush Exceptionrrstdoutwrite) roptionsr connectionrrr r r app_configsql_listconfirmexcrrrhandlesR       zCommand.handleN)__name__ __module__ __qualname__rstealth_optionsrr1rrrrr s  r N) importlibr django.appsrdjango.core.management.baserrdjango.core.management.colorrdjango.core.management.sqlrr django.dbr r r rrrrs