I added field to my model in banks app, run python manage.py schemamigration banks --auto which generates correct migration but after migrate, don't know why South start over from initial migration.
python manage.py migrate banks
Running migrations for banks:
- Migrating forwards to 0038_auto__add_field_offer_description.
> banks:0001_initial
FATAL ERROR - The following SQL query failed: CREATE TABLE `banks_lendingtarget` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(255) NOT NULL UNIQUE)
The error was: (1050, "Table 'banks_lendingtarget' already exists")
Even if I start migrate with specified migration name like:
python manage.py migrate banks 0038_auto__add_field_offer_description
There is the same error, and my question is: why?
I was thinking that recently added initial_data.json to my app can cause this but after renaming it nothing changes. Have anyone of You have same situation? Thanks for help.
This is assuming you are using South 0.8 or so and Django 1.6 or below:
I can't explain why this happened without knowing more about the history of your database and South usage, but to help in diagnosing the issue you could manually inspect the South migration history table in your database.
However, whatever you find out, the remedy is likely to be the same: you can "fake" the migration and skip ahead to the proper place in your migration history.
Try python manage.py migrate banks 0037 --fake
. That will take you to just BEFORE the 0038
migration without actually trying to create tables. Of course, this assumes that 0037
is the most recent migration that was successfully applied to your database.