我已使用architect对现有表进行分区。
@architect.install('partition', type='range', subtype='integer', constraint='100', column='id')
class Project(models.Model):
name = models.CharField(max_length=150)
项目模型用作另一个模型的外键。
class ProjectChangeLog(models.Model):
project = models.ForeignKey(Project, on_delete=models.CASCADE)
分区后,我无法添加任何ProjectChangeLog对象。它说:
IntegrityError: insert or update on table "logging_projectchangelog" violates foreign key constraint
DETAIL: Key (project_id)=(231) is not present in table "project_project"