简体   繁体   English

Django南迁徙问题

[英]django south migration issue

i am really stuck here. 我真的被困在这里。 i have a model, where i am migrating well untill now. 我有一个模型,直到现在我一直在良好地迁移。 but today i added new field, then i did schemamigration app --auto , then it found the newly added field, but when i ran migrate app , it says, the field newfield doesnot exist. 但是今天我添加了一个新字段,然后执行了schemamigration app --auto ,然后找到了新添加的字段,但是当我运行newfield migrate app ,它说该字段newfield不存在。 i dont understand why. 我不明白为什么。 i uncommented and tried to schemamigration and migrate again, it is spitting out the same error now. 我没有评论,并尝试进行schemamigration和再次迁移,它现在吐出了同样的错误。 what did i wrong and what should i do now? 我错了什么,现在应该怎么办? i want to have a fixed steps for such cases :( 我想对这种情况有一个固定的步骤:(

thanks for help 感谢帮助

edit: 编辑:

class User(models.Model):
  registerdate = models.CharField(max_length=400,default='')
  vorname = models.CharField(max_length=100,default='')
  nachname = models.CharField(max_length=100,default='')
  plz = models.CharField(max_length=10,default='')  <------------- this field i added
  land = models.CharField(max_length=100,default='')

the error says: 错误说:

the following sql statement failed: ALTER TABLE home_user DROP COLUMN plz CASCADE;

but now, i have this field uncommented and if i try to migrate, it says: column PLZ of Relation USER does not exist. 但是现在,我没有对此字段进行注释,如果我尝试迁移,它会说:Relation USER PLZ列不存在。 why is this? 为什么是这样? :( :(

i uncommented and tried to schemamigration and migrate again, it is spitting out the same error now. 我没有评论,并尝试进行schemamigration和再次迁移,它现在吐出了同样的错误。

Did you delete the migration you created after adding the new field? 添加新字段后,您是否删除了创建的迁移? If not, then running migrate will keep trying to run this migration. 如果没有,则运行迁移将继续尝试运行此迁移。 Since you say it failed to run the first time, it will always keep failing to run unless it's corrected or deleted. 由于您说它是第一次运行失败,因此除非纠正或删除它,否则它将始终保持运行失败。

If that first migration really did fail to run, you could try deleting it (and any subsequent migrations you may have created), then recreating it. 如果该第一次迁移确实确实无法运行,则可以尝试将其删除(以及您可能创建的任何后续迁移),然后重新创建它。

Before trying that, though, it would be helpful for you to post more complete tracebacks of the errors you get when you run migrate. 但是,在尝试此操作之前,对运行迁移时遇到的错误发布更完整的追溯将很有帮助。 You may have a mismatch between what south thinks the state of your database is and what it actually is, but it's hard to say for sure without more information. South认为数据库状态与实际状态之间可能会有所不符,但是如果没有更多信息,很难确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM