diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index 8e8330484d2..8f328988340 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -310,9 +310,8 @@ class ManagementUtility(object): from django.core.servers.fastcgi import FASTCGI_OPTIONS options += [(k, 1) for k in FASTCGI_OPTIONS] # special case: add the names of installed apps to options - elif cwords[0] in ('dumpdata', 'reset', 'sql', 'sqlall', - 'sqlclear', 'sqlcustom', 'sqlindexes', - 'sqlreset', 'sqlsequencereset', 'test'): + elif cwords[0] in ('dumpdata', 'sql', 'sqlall', 'sqlclear', + 'sqlcustom', 'sqlindexes', 'sqlsequencereset', 'test'): try: from django.conf import settings # Get the last part of the dotted path as the app name. diff --git a/django/core/management/commands/reset.py b/django/core/management/commands/reset.py deleted file mode 100644 index e45edb70d80..00000000000 --- a/django/core/management/commands/reset.py +++ /dev/null @@ -1,62 +0,0 @@ -from optparse import make_option - -from django.core.management.base import AppCommand, CommandError -from django.core.management.color import no_style -from django.core.management.sql import sql_reset -from django.db import connections, transaction, DEFAULT_DB_ALIAS - -class Command(AppCommand): - option_list = AppCommand.option_list + ( - make_option('--noinput', action='store_false', dest='interactive', default=True, - help='Tells Django to NOT prompt the user for input of any kind.'), - make_option('--database', action='store', dest='database', - default=DEFAULT_DB_ALIAS, help='Nominates a database to reset. ' - 'Defaults to the "default" database.'), - ) - help = "Executes ``sqlreset`` for the given app(s) in the current database." - args = '[appname ...]' - - output_transaction = True - - def handle_app(self, app, **options): - # This command breaks a lot and should be deprecated - import warnings - warnings.warn( - 'This command has been deprecated. The command ``flush`` can be used to delete everything. You can also use ALTER TABLE or DROP TABLE statements manually.', - DeprecationWarning - ) - using = options.get('database') - connection = connections[using] - - app_name = app.__name__.split('.')[-2] - self.style = no_style() - - sql_list = sql_reset(app, self.style, connection) - - if options.get('interactive'): - confirm = raw_input(""" -You have requested a database reset. -This will IRREVERSIBLY DESTROY any data for -the "%s" application in the database "%s". -Are you sure you want to do this? - -Type 'yes' to continue, or 'no' to cancel: """ % (app_name, connection.settings_dict['NAME'])) - else: - confirm = 'yes' - - if confirm == 'yes': - try: - cursor = connection.cursor() - for sql in sql_list: - cursor.execute(sql) - except Exception, e: - transaction.rollback_unless_managed() - raise CommandError("""Error: %s couldn't be reset. Possible reasons: - * The database isn't running or isn't configured correctly. - * At least one of the database tables doesn't exist. - * The SQL was invalid. -Hint: Look at the output of 'django-admin.py sqlreset %s'. That's the SQL this command wasn't able to run. -The full error: %s""" % (app_name, app_name, e)) - transaction.commit_unless_managed() - else: - print "Reset cancelled." diff --git a/django/core/management/commands/sqlreset.py b/django/core/management/commands/sqlreset.py deleted file mode 100644 index 976b8488863..00000000000 --- a/django/core/management/commands/sqlreset.py +++ /dev/null @@ -1,20 +0,0 @@ -from optparse import make_option - -from django.core.management.base import AppCommand -from django.core.management.sql import sql_reset -from django.db import connections, DEFAULT_DB_ALIAS - -class Command(AppCommand): - help = "Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s)." - - option_list = AppCommand.option_list + ( - make_option('--database', action='store', dest='database', - default=DEFAULT_DB_ALIAS, help='Nominates a database to print the ' - 'SQL for. Defaults to the "default" database.'), - - ) - - output_transaction = True - - def handle_app(self, app, **options): - return u'\n'.join(sql_reset(app, self.style, connections[options.get('database')])).encode('utf-8') diff --git a/django/core/management/sql.py b/django/core/management/sql.py index 19b7ec2cd71..454a3427aac 100644 --- a/django/core/management/sql.py +++ b/django/core/management/sql.py @@ -96,16 +96,6 @@ def sql_delete(app, style, connection): return output[::-1] # Reverse it, to deal with table dependencies. -def sql_reset(app, style, connection): - "Returns a list of the DROP TABLE SQL, then the CREATE TABLE SQL, for the given module." - # This command breaks a lot and should be deprecated - import warnings - warnings.warn( - 'This command has been deprecated. The command ``sqlflush`` can be used to delete everything. You can also use ALTER TABLE or DROP TABLE statements manually.', - DeprecationWarning - ) - return sql_delete(app, style, connection) + sql_all(app, style, connection) - def sql_flush(style, connection, only_django=False): """ Returns a list of the SQL statements used to flush the database. diff --git a/docs/howto/initial-data.txt b/docs/howto/initial-data.txt index 36306d476e0..557935f2660 100644 --- a/docs/howto/initial-data.txt +++ b/docs/howto/initial-data.txt @@ -124,10 +124,9 @@ Each SQL file, if given, is expected to contain valid SQL statements which will insert the desired data (e.g., properly-formatted ``INSERT`` statements separated by semicolons). -The SQL files are read by the :djadmin:`sqlcustom`, :djadmin:`sqlreset`, -:djadmin:`sqlall` and :djadmin:`reset` commands in :doc:`manage.py -`. Refer to the :doc:`manage.py documentation -` for more information. +The SQL files are read by the :djadmin:`sqlcustom` and :djadmin:`sqlall` +commands in :doc:`manage.py `. Refer to the :doc:`manage.py +documentation ` for more information. Note that if you have multiple SQL data files, there's no guarantee of the order in which they're executed. The only thing you can assume is diff --git a/docs/man/django-admin.1 b/docs/man/django-admin.1 index 1f693b89751..d336da0f7be 100644 --- a/docs/man/django-admin.1 +++ b/docs/man/django-admin.1 @@ -65,11 +65,6 @@ Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for project and application) directory. .TP -.BI "reset [" "appname ..." "]" -Executes -.B sqlreset -for the given app(s) in the current database. -.TP .BI "runfcgi [" "KEY=val" "] [" "KEY=val" "] " "..." Runs this project as a FastCGI application. Requires flup. Use .B runfcgi help @@ -107,10 +102,6 @@ Prints the CREATE INDEX SQL statements for the given model module name(s). .BI "sqlinitialdata [" "appname ..." "]" Prints the initial INSERT SQL statements for the given app name(s). .TP -.BI "sqlreset [" "appname ..." "]" -Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app -name(s). -.TP .BI "sqlsequencereset [" "appname ..." "]" Prints the SQL statements for resetting PostgreSQL sequences for the given app name(s). diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index 5ea72803fb3..845db155000 100644 --- a/docs/ref/django-admin.txt +++ b/docs/ref/django-admin.txt @@ -484,25 +484,6 @@ Use the ``--no-location`` option to not write '``#: filename:line``' comment lines in language files. Note that using this option makes it harder for technically skilled translators to understand each message's context. -reset ---------------------------- - -.. deprecated:: 1.3 - This command has been deprecated. The ``flush`` can be used to delete - everything. You can also use ALTER TABLE or DROP TABLE statements manually. - -.. django-admin:: reset - -Executes the equivalent of ``sqlreset`` for the given app name(s). - -The :djadminopt:`--noinput` option may be provided to suppress all user -prompts. - -.. versionadded:: 1.2 - -The :djadminopt:`--database` option can be used to specify the alias -of the database to reset. - runfcgi [options] ----------------- @@ -874,22 +855,6 @@ Prints the CREATE INDEX SQL statements for the given app name(s). The :djadminopt:`--database` option can be used to specify the database for which to print the SQL. -sqlreset ------------------------------- - -.. deprecated:: 1.3 - This command has been deprecated. The ``sqlflush`` can be used to delete - everything. You can also use ALTER TABLE or DROP TABLE statements manually. - -.. django-admin:: sqlreset - -Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s). - -.. versionadded:: 1.2 - -The :djadminopt:`--database` option can be used to specify the database for -which to print the SQL. - sqlsequencereset -------------------------------------- diff --git a/tests/regressiontests/bash_completion/tests.py b/tests/regressiontests/bash_completion/tests.py index 0206c37482a..e4b3bb58f34 100644 --- a/tests/regressiontests/bash_completion/tests.py +++ b/tests/regressiontests/bash_completion/tests.py @@ -66,7 +66,7 @@ class BashCompletionTests(unittest.TestCase): "Subcommands can be autocompleted" self._user_input('django-admin.py sql') output = self._run_autocomplete() - self.assertEqual(output, ['sql sqlall sqlclear sqlcustom sqlflush sqlindexes sqlinitialdata sqlreset sqlsequencereset']) + self.assertEqual(output, ['sql sqlall sqlclear sqlcustom sqlflush sqlindexes sqlinitialdata sqlsequencereset']) def test_help(self): "No errors, just an empty list if there are no autocomplete options"