Django migration with uuid field generates duplicated values

前端 未结 4 406
庸人自扰
庸人自扰 2020-12-05 16:58

I have a uuid field (not a primary key). The generated migration is:

from __future__ import unicode_literals

from django.db import migrations,          


        
4条回答
  •  眼角桃花
    2020-12-05 17:28

    (Answer taken from the first comment)

    See the django docs - Migrations that add unique fields

    They recommend changing your single migration into three separate migrations:

    1. Create field, set to null but not unique
    2. Generate unique UUIDs
    3. Alter the field to be unique

提交回复
热议问题