【发布时间】:2021-07-08 10:05:07
【问题描述】:
我正在尝试使用 Django 2.2 运行以下迁移:
class Migration(migrations.Migration):
dependencies = [
('actstream', '0002_remove_action_data'),
]
operations = [
migrations.AddField(
model_name='follow',
name='flag',
field=models.CharField(blank=True, db_index=True, default='', max_length=255),
),
migrations.AlterUniqueTogether(
name='follow',
unique_together=set([('user', 'content_type', 'object_id', 'flag')]),
),
]
添加迁移的 git commit 之前模型有以下约束:
unique_together = ('user', 'content_type', 'object_id')
在添加迁移的 git commit 之后:
unique_together = ('user', 'content_type', 'object_id', 'flag')
(flag 是一个新字段,它也被添加到unique_together 约束中)。
当我尝试应用迁移时,我收到以下错误消息:
psycopg2.errors.UndefinedObject: constraint "actstream_follow_user_id_content_type_id_object_id" of relation "actstream_follow" does not exist
检查我的数据库,因为它是没有迁移,但是,我看到以下内容:
我错过了什么?
谢谢!
【问题讨论】:
标签: django