Commits

Anonymous committed cb00e0a

Make syncdb actually work this time! I tested it and everything.

  • Participants
  • Parent commits 2fc72aa

Comments (0)

Files changed (2)

File management/commands/syncdb.py

 from django.db.models.loading import cache
 import sys
 
+def get_app_name(app):
+    return '.'.join( app.__name__.split('.')[0:-1] )
+
 class Command(NoArgsCommand):
     option_list = NoArgsCommand.option_list + (
         make_option('--verbosity', action='store', dest='verbosity', default='1',
         apps_needing_sync = []
         apps_migrated = []
         for app in models.get_apps():
-            app_name = '.'.join( app.__name__.split('.')[0:-1] )
+            app_name = get_app_name(app)
             migrations = migration.get_migrations(app)
             if migrations is None:
                 apps_needing_sync.append(app_name)
         old_installed, settings.INSTALLED_APPS = settings.INSTALLED_APPS, apps_needing_sync
         old_app_store, cache.app_store = cache.app_store, SortedDict([
             (k, v) for (k, v) in cache.app_store.items()
-            if k in apps_needing_sync
+            if get_app_name(k) in apps_needing_sync
         ])
         syncdb.Command().execute(**options)
         settings.INSTALLED_APPS = old_installed

File migration.py

     for migration in migrations:
         print " > %s" % migration
         klass = get_migration(app_name, migration)
-        klass().forwards()
+        if fake:
+            print "   (faked)"
+        else:
+            klass().forwards()
         # Record us as having done this
         record = MigrationHistory.for_migration(app_name, migration)
         record.applied = datetime.datetime.utcnow()
         if migration not in ignore:
             print " < %s" % migration
             klass = get_migration(app_name, migration)
-            klass().backwards()
+            if fake:
+                print "   (faked)"
+            else:
+                klass().backwards()
             # Record us as having not done this
             record = MigrationHistory.for_migration(app_name, migration)
             record.delete()
 
 
-def migrate_app(migration_module, target_name=None, resolve_mode=None):
+def migrate_app(migration_module, target_name=None, resolve_mode=None, fake=False):
     
     # Work out exactly what we're working on
     app_name = os.path.splitext(migration_module.__name__)[0]