I recently added South to an existing Django project. I went through everything
python manage.py syncdb python manage.py convert_to_south myapp python manage.py migrate myapp 0001 --fake
processed according to the last comment on this ticket (because I have a custom model).
Then I think I did a sketching and migrated? I donโt quite remember, but in the end I had two migration files, called 0001_initial.py and 0002_initial.py , which didnโt look exactly the same.
Today I tried to add a field to one of my models and perform the migration as follows:
$ python manage.py schemamigration myapp --auto ? The field 'Photo.main_person' does not have a default specified, yet is NOT NULL. ? Since you are adding this field, you MUST specify a default ? value to use for existing rows. Would you like to: ? 1. Quit now, and add a default to the field in models.py ? 2. Specify a one-off value to use for existing columns now ? Please select a choice: 2 ? Please enter Python code for your one-off default value. ? The datetime module is available, so you can do eg datetime.date.today() >>> 1 + Added field main_person on myapp.Photo Created 0003_auto__add_field_photo_main_person.py. You can now apply this migration with: ./manage.py migrate myapp $ python manage.py migrate myapp Running migrations for myapp: - Migrating forwards to 0003_auto__add_field_photo_main_person. > myapp:0002_initial FATAL ERROR - The following SQL query failed: CREATE TABLE "myapp_patient" ("id" serial NOT NULL PRIMARY KEY, "password" varchar(128) NOT NULL, "last_login" timestamp with time zone NOT NULL, "email" varchar(255) NOT NULL UNIQUE, "first_name" varchar(100) NOT NULL, "last_name" varchar(100) NOT NULL, "is_active" boolean NOT NULL, "is_admin" boolean NOT NULL, "is_staff" boolean NOT NULL) The error was: relation "myapp_patient" already exists Error in migration: myapp:0002_initial DatabaseError: relation "myapp_patient" already exists
So, he created the migration 0003_auto__add_field_photo_main_person , but it seems that she could not go through the second migration. Should / I can just delete the second migration file? This is exactly the same as the first one that seems to be causing the problem, but I'm not good enough in the South to find out if this is a good idea.
source share