diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-02-26 11:26:41 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-02-26 11:26:41 +0000 |
| commit | 126ca330e230034081182ec8a4bf1f47260b6cb9 (patch) | |
| tree | cbf35fb5b67bcae44b7dea1913edf34d79caff42 | |
| parent | e488c1dc0d29f2de0d8bb31db604aa6384b7a60b (diff) | |
Fixed #12712 -- Corrected a problem with synchronizing that prevented m2m tables from being created under certain circumstances. Thanks to IonelMaries for the report, and Alex Gaynor for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12597 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/management/commands/syncdb.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py index e7b4b46623..1fa4d199d3 100644 --- a/django/core/management/commands/syncdb.py +++ b/django/core/management/commands/syncdb.py @@ -63,6 +63,16 @@ class Command(NoArgsCommand): if router.allow_syncdb(db, m)]) for app in models.get_apps() ) + def model_installed(model): + opts = model._meta + converter = connection.introspection.table_name_converter + return not ((converter(opts.db_table) in tables) or + (opts.auto_created and converter(opts.auto_created._meta.db_table) in tables)) + + manifest = dict( + (app_name, filter(model_installed, model_list)) + for app_name, model_list in manifest.iteritems() + ) # Create the tables for each model for app_name, model_list in manifest.items(): @@ -70,11 +80,6 @@ class Command(NoArgsCommand): # Create the model's database table, if it doesn't already exist. if verbosity >= 2: print "Processing %s.%s model" % (app_name, model._meta.object_name) - opts = model._meta - if (connection.introspection.table_name_converter(opts.db_table) in tables or - (opts.auto_created and - connection.introspection.table_name_converter(opts.auto_created._meta.db_table) in tables)): - continue sql, references = connection.creation.sql_create_model(model, self.style, seen_models) seen_models.add(model) created_models.add(model) |
