Skip to main content

Command

This class prints the SQL statements required to reset sequences for a specified set of application models. It allows users to nominate a specific database and generates the necessary SQL to synchronize sequence values with their associated table data.

Attributes

AttributeTypeDescription
helpstring = Prints the SQL statements for resetting sequences for the given app name(s).Prints the SQL statements for resetting sequences for the given app name(s).
output_transactionboolean = trueA boolean flag indicating whether the output SQL should be wrapped in a transaction block.

Methods


add_arguments()

@classmethod
def add_arguments(
parser: ArgumentParser
) - > null

Configures the argument parser to include a database selection flag for the command.

Parameters

NameTypeDescription
parserArgumentParserThe argument parser instance to which the --database argument and other base arguments are added

Returns

TypeDescription
nullNothing is returned; the parser object is modified in place.

handle_app_config()

@classmethod
def handle_app_config(
app_config: [AppConfig](../../../../apps/config/appconfig.md?sid=django_apps_config_appconfig),
**options: dict
) - > string

Generates the SQL statements required to reset sequences for the models within a specific application configuration.

Parameters

NameTypeDescription
app_config[AppConfig](../../../../apps/config/appconfig.md?sid=django_apps_config_appconfig)The configuration object for the application whose sequences are being processed
**optionsdictA dictionary of runtime options, including the target database alias and verbosity level

Returns

TypeDescription
stringA newline-separated string of SQL statements for resetting sequences, or an empty string if no sequences are found.