[英]Django: Foreign Key to a partitioned table
I have used architect to partition an existing table. 我已经使用架构师对现有表进行分区。
@architect.install('partition', type='range', subtype='integer', constraint='100', column='id')
class Project(models.Model):
name = models.CharField(max_length=150)
The project model was used as a foreign key to another model. 项目模型被用作另一个模型的外键。
class ProjectChangeLog(models.Model):
project = models.ForeignKey(Project, on_delete=models.CASCADE)
After partitioning, I could not add any ProjectChangeLog objects. 分区后,我无法添加任何ProjectChangeLog对象。 It says: 它说:
IntegrityError: insert or update on table "logging_projectchangelog" violates foreign key constraint
DETAIL: Key (project_id)=(231) is not present in table "project_project"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.