How fix problemm django.db.utils.IntegrityError: UNIQUE constraint failed?
My migration has the form `# -- coding: utf-8 --
Generated by Django 1.9.2 on 2016-03-03 15:52
from future import unicode_literals
from django.db import migrations import shortuuidfield.fields
class Migration(migrations.Migration):
dependencies = [
('patient', '0006_auto_20160226_0005'),
]
operations = [
migrations.AddField(
model_name='customer',
name='uuid',
field=shortuuidfield.fields.ShortUUIDField(blank=True, editable=False, max_length=22, unique=True),
),
]
`
When I try to run migrate myapp, I get the error table patient_customer has no column named uuid
@alimuradov I had this same problem, and found documentation on Adding a unique field in the migrations documentation.
Basically: You add the field without unique=true in one operation, make a data migration that generates the correct shortuuids for you, and then change the field too unique again.
DO THESE python manage.py migrate --fake python manage.py makemigrations python manage.py migrate python manage.py runserver the above commands should sort them all out
I'm no longer using or in a position to test this library, but am happy to review and merge any PR's that address this or other issues if you're finding the library to be helpful.
DO THESE python manage.py migrate --fake python manage.py makemigrations python manage.py migrate python manage.py runserver the above commands should sort them all out
I didn't understand completely what happened but it's work for me Thank You <3
DO THESE python manage.py migrate --fake python manage.py makemigrations python manage.py migrate python manage.py runserver the above commands should sort them all out
Thanks you, the solution is great.
I get this error even after I get rid of the unique field or set it to false, which I think is a key point that no one has pointed out yet that makes the error so devious.
DO THESE python manage.py migrate --fake python manage.py makemigrations python manage.py migrate python manage.py runserver the above commands should sort them all out
This doesn't work for me. There is no update between the fake and real migrations, and the database column missing error I have due to the original issue is not handled.
what actually is this but its working fine
Tenta definir default=uuid.uuid4 do champo no model UUIDField.