- for mapp, mname in forwards:
- if (mapp, mname) not in current_migrations:
- run_forwards(mapp, [mname], fake=fake, silent=silent)
+ try:
+ for mapp, mname in forwards:
+ if (mapp, mname) not in current_migrations:
+ result = run_forwards(mapp, [mname], fake=fake, db_dry_run=db_dry_run, silent=silent)
+ if result is False: # The migrations errored, but nicely.
+ return
+ finally:
+ # Call any pending post_syncdb signals
+ db.send_pending_create_signals()
+ # Now load initial data, only if we're really doing things and ended up at current
+ if not fake and not db_dry_run and load_inital_data and target_name == migrations[-1]:
+ print " - Loading initial data for %s." % app_name
+ # Override Django's get_apps call temporarily to only load from the
+ # current app
+ old_get_apps, models.get_apps = (
+ models.get_apps,
+ lambda: [models.get_app(get_app_name(app))],
+ )
+ # Load the initial fixture
+ call_command('loaddata', 'initial_data', verbosity=1)
+ # Un-override
+ models.get_apps = old_get_apps