Command
This class provides a command-line interface to generate the SQL statements required to reset all tables in a database to their initial post-installation state. It supports targeting specific databases via an optional argument and ensures the resulting output is wrapped in a transaction. The class utilizes database-specific utilities to identify and format the necessary flush operations.
Attributes
| Attribute | Type | Description |
|---|---|---|
| help | string | Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed. |
| output_transaction | boolean = True | A boolean flag indicating whether the command's output should be wrapped in a database transaction. |
Methods
add_arguments()
@classmethod
def add_arguments(
parser: [CommandParser](../../base/commandparser.md?sid=django_core_management_base_commandparser)
) - > null
Configures the command-line argument parser to include custom options for database selection.
Parameters
| Name | Type | Description |
|---|---|---|
| parser | [CommandParser](../../base/commandparser.md?sid=django_core_management_base_commandparser) | The argument parser instance used to define command-line flags and options. |
Returns
| Type | Description |
|---|---|
null | Nothing is returned; the parser object is modified in place. |
handle()
@classmethod
def handle(
**options: dict
) - > string
Generates and returns a list of SQL statements required to reset all database tables to their post-installation state.
Parameters
| Name | Type | Description |
|---|---|---|
| **options | dict | A dictionary of command-line arguments, including the target database alias and verbosity level. |
Returns
| Type | Description |
|---|---|
string | A newline-separated string of SQL statements used to flush the database tables. |