Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #46 from dcramer/improve-syncdb

Improve SyncDB
  • Loading branch information...
commit 4398773116133722d15412e240ba2a140ebc481b 2 parents 5050420 + 820991e
@paltman authored
View
8 nashvegas/management/commands/syncdb.py
@@ -4,4 +4,10 @@
class Command(SyncDBCommand):
def handle_noargs(self, **options):
- call_command("upgradedb", do_execute=True)
+ # Run migrations first
+ # {'load_initial_data': False, 'verbosity': 1, 'interactive': False, 'database': 'default'}
+ call_command("upgradedb", do_execute=True, database=options.get('database'), verbosity=options.get('verbosity'))
+
+ # Follow up with a syncdb on anything that wasnt included in migrations
+ # (this catches things like test-only models)
+ super(Command, self).handle_noargs(**options)
View
16 nashvegas/management/commands/upgradedb.py
@@ -263,13 +263,14 @@ def execute_migrations(self, show_traceback=True):
db=db,
)
- sys.stdout.write("Running loaddata for initial_data fixtures on %r.\n" % db)
- call_command(
- "loaddata",
- "initial_data",
- verbosity=self.verbosity,
- database=db,
- )
+ if self.load_initial_data:
+ sys.stdout.write("Running loaddata for initial_data fixtures on %r.\n" % db)
+ call_command(
+ "loaddata",
+ "initial_data",
+ verbosity=self.verbosity,
+ database=db,
+ )
def seed_migrations(self, stop_at=None):
# @@@ the command-line interface needs to be re-thinked
@@ -332,6 +333,7 @@ def handle(self, *args, **options):
self.do_create = options.get("do_create")
self.do_create_all = options.get("do_create_all")
self.do_seed = options.get("do_seed")
+ self.load_initial_data = options.get("load_initial_data", True)
self.args = args
if options.get("path"):
Please sign in to comment.
Something went wrong with that request. Please try again.