I have created a model and executed syncdb which had created the tables as my model was designed.
Afterwards I modified the model and executed makemigrations
which created the migrations ignoring the tables that syncdb had already created.
So I ended up with an error "relation already exists".
Why did makemigrations created everything from scratch? How do I fix this situation ?
makemigrations
creates new migrations based on the changes detected to your models.
Also, one thing to note is syncdb
command is deprecated since Django 1.7 and will be removed in Django 1.9. So, you should use the migrate
command.
From syncdb
docs:
Deprecated since version 1.7:
This command has been deprecated in favor of themigrate
command, which performs both the old behavior as well as executing migrations.