|
@@ -5,7 +5,6 @@ from importlib import import_module
|
|
|
|
|
|
from django.apps import apps
|
|
|
from django.db import connections, router, transaction, DEFAULT_DB_ALIAS
|
|
|
-from django.core.management import call_command
|
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
|
from django.core.management.color import no_style
|
|
|
from django.core.management.sql import sql_flush, emit_post_migrate_signal
|
|
@@ -15,8 +14,7 @@ from django.utils import six
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
help = ('Removes ALL DATA from the database, including data added during '
|
|
|
- 'migrations. Unmigrated apps will also have their initial_data '
|
|
|
- 'fixture reloaded. Does not achieve a "fresh install" state.')
|
|
|
+ 'migrations. Does not achieve a "fresh install" state.')
|
|
|
|
|
|
def add_arguments(self, parser):
|
|
|
parser.add_argument('--noinput', action='store_false', dest='interactive', default=True,
|
|
@@ -24,9 +22,6 @@ class Command(BaseCommand):
|
|
|
parser.add_argument('--database', action='store', dest='database',
|
|
|
default=DEFAULT_DB_ALIAS,
|
|
|
help='Nominates a database to flush. Defaults to the "default" database.')
|
|
|
- parser.add_argument('--no-initial-data', action='store_false',
|
|
|
- dest='load_initial_data', default=True,
|
|
|
- help='Tells Django not to load any initial data after database synchronization.')
|
|
|
|
|
|
def handle(self, **options):
|
|
|
database = options.get('database')
|
|
@@ -82,16 +77,6 @@ Are you sure you want to do this?
|
|
|
|
|
|
if not inhibit_post_migrate:
|
|
|
self.emit_post_migrate(verbosity, interactive, database)
|
|
|
-
|
|
|
- # Reinstall the initial_data fixture.
|
|
|
- if options.get('load_initial_data'):
|
|
|
- # Reinstall the initial_data fixture for apps without migrations.
|
|
|
- from django.db.migrations.executor import MigrationExecutor
|
|
|
- executor = MigrationExecutor(connection)
|
|
|
- app_options = options.copy()
|
|
|
- for app_label in executor.loader.unmigrated_apps:
|
|
|
- app_options['app_label'] = app_label
|
|
|
- call_command('loaddata', 'initial_data', **app_options)
|
|
|
else:
|
|
|
self.stdout.write("Flush cancelled.\n")
|
|
|
|