3

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.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
user3282276
  • 3,674
  • 8
  • 32
  • 48

1 Answers1

5

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.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • Thanks for the answer but what exactly does it mean for the databases to be out of sync? – user3282276 Jul 06 '14 at 21:32
  • 1
    When you migrate your schema using south, it stores information that the migration has been 'done' in the database. If you create the table using.`syncdb --all`, then the table is created, but the migration data is not updated, so the database schema and migrations are out of sync. – Alasdair Jul 06 '14 at 22:13