Django & South: Adding new field but DatabaseError occurs “table already exists”

后端 未结 3 1515
旧时难觅i
旧时难觅i 2021-02-06 17:55

In trying to add a new field to a preexisting Model/table, I get a DatabaseError with \'table already exists.\' I have run migrations before this one so I am a bit puzzled why a

相关标签:
3条回答
  • 2021-02-06 18:15

    You need to do schemamigration app --initial first without your new field, then migrate app --fake 0001 (or whichever migration number it returned) to set the south database to that state (tables already created).

    Add your new field, then run schemamigration myapp --auto, then migrate.

    0 讨论(0)
  • 2021-02-06 18:27

    I commented out the field, ran schemamigration, then migrate. Uncommented out the field, ran schemamigration, then migrate and it worked. Not sure what I was doing wrong.

    0 讨论(0)
  • 2021-02-06 18:28

    This happens when you doing something on migration and did not let south knows about it.

    If you looking at the south_* table in the database, you will find-out south keeps logs about db migrations in the database. The common way is to faking the migration. There is a fake argument for the South.

    here you can find out what is all about: http://south.readthedocs.org/en/latest/commands.html#options

    0 讨论(0)
提交回复
热议问题