Django South - 表已经存在 [英] Django South - table already exists

查看:90
本文介绍了Django South - 表已经存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力开始南方。我有一个现有的数据库,我添加了南( syncdb schemamigration --initial )。



然后,我更新了 models.py 添加一个字段并运行 ./ manage.py schemamigration myapp - 自动。似乎找到了这个字段,并说我可以用 ./ manage.py migrate myapp 应用这个字段。但是,这样做会出错:

  django.db.utils.DatabaseError:表myapp_tablename已经存在

tablename models.py 。



我正在运行Django 1.2,South 0.7

解决方案

由于您已经在数据库中创建了表,您只需要运行初始迁移作为假的

  ./ manage.py migrate myapp --fake 

确保模式模型与数据库中表格的模式相同。


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

Then, I updated models.py to add a field and ran ./manage.py schemamigration myapp --auto. It seemed to find the field and said I could apply this with ./manage.py migrate myapp. But, doing that gave the error:

django.db.utils.DatabaseError: table "myapp_tablename" already exists

tablename is the first table listed in models.py.

I am running Django 1.2, South 0.7

解决方案

since you already have the tables created in the database, you just need to run the initial migration as fake

./manage.py migrate myapp --fake

make sure that the schema of models is same as schema of tables in database.

这篇关于Django South - 表已经存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆