Postgres抱怨不存在约束

时间:2018-03-14 15:56:18

标签: django postgresql django-models

我正在迁移postgresql中的数据库模式,我在Django(1.11.11)中收到此错误:

        django.db.utils.ProgrammingError: constraint 
"djstripe_charge_account_id_597fef70_fk_djstripe_account_id" for relation "djstripe_charge" already exists

但是在ALTER TABLE djstripe_charge DROP CONSTRAINT djstripe_charge_account_id_597fef70_fk_djstripe_account_id ;中执行psql会出现以下错误:

ERROR:  constraint "djstripe_charge_account_id_597fef70_fk_djstripe_account_id"
 of relation "djstripe_charge" does not exist

我在psql中使用\d djstripe_charge进行了验证,并且没有显示在关系列表

在django中,迁移代码中出现错误(90%肯定):

    migrations.AddField(
        model_name='charge',
        name='account',
        field=models.ForeignKey(help_text='The account the charge was made on behalf of. Null here indicates that this value was never set.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='charges', to='djstripe.Account'),
    ),

为什么Django抱怨这个?

0 个答案:

没有答案