【发布时间】:2023-04-06 07:20:01
【问题描述】:
我正在尝试删除在两个模型字段中定义的 unique 约束(使用 South 0.8.2)。
我需要从:
billing_id = models.PositiveIntegerField(_("Billing id"), unique=True, blank=True, null=True)
tax_code = models.CharField(_("Tax code"), max_length=10, unique=True, blank=True, null=True)
收件人:
billing_id = models.PositiveIntegerField(_("Billing id"), blank=True, null=True)
tax_code = models.CharField(_("Tax code"), max_length=10, blank=True, default='')
但是,当我运行迁移时,我收到以下错误:
Warning: Data truncated for column 'tax_code' at row 1
如果我再次运行它,我会得到:
ValueError: Cannot find a UNIQUE constraint on table startups_startup, columns ['billing_id']
到了这一步,我不得不手动重新创建唯一索引。
表上有现有记录,我正在使用 MySQL。
有没有“简单的方法”来做到这一点?
【问题讨论】:
标签: mysql django django-south