djangodjango-1.6django-syncdb

Clarification on django syncdb --all option


I am trying to understand what exactly ./manage.py syncdb --all does? I recently had a database issue that I was able to fix by running this command but I am not exactly sure what it does behind the scenes. I understand that syncdb creates the tables for the installed apps that aren't being migrated with south and that those that are under south migration control are overlooked unless the --all option is specified but I am confused by what actually happens and when to use it. I am unable to find anything about the option on the django-admin docs and the man pages only say this about the option.

--all                 Makes syncdb work on all apps, even migrated ones. Be
                        careful!

Why do I need to be careful? What exactly is this doing? Is it completely deleting the database and starting over, which I assume would cause me to lose all of my data stored in the database (right?), or is something else happening here? I am using Django 1.6 if that makes a difference.


Solution

  • When you install south, it replaces Django's syncdb command with its own. It is the south version of syncdb that has the --all option, but its not recommended:

    If you want to run syncdb on all of the apps, then use --all, but be warned; this will put your database schema and migrations out of sync. If you do this, you might be able to fix it with:

    The syncdb command never deletes tables. You need to be careful because you don't want the database schema and migrations to get out of sync.