Django South - table already exists

前端 未结 8 584
名媛妹妹
名媛妹妹 2020-12-02 03:55

I am trying to get started with South. I had an existing database and I added South (syncdb, schemamigration --initial).

Then, I updated <

8条回答
  •  攒了一身酷
    2020-12-02 04:04

    As temporary solution, you can comment the Table creation in the migration script.

    class Migration(migrations.Migration):
    
        dependencies = [
            (...)
        ]
    
        operations = [
            #migrations.CreateModel(
            #    name='TABLE',
            #    fields=[
            #            ....
            #            ....
            #    ],
            #),
            ....
            ....
    

    Or

    If the existing table contains no rows (empty), then consider deleting the table like below. (This fix is recommended only if the table contains no rows). Also make sure this operation before the createModel operation.

    class Migration(migrations.Migration):
    
        dependencies = [
            (...),
        ]
    
        operations = [
            migrations.RunSQL("DROP TABLE myapp_tablename;")
        ]
    

提交回复
热议问题