0

I am trying to implement a unique_together constraint on one of the models in my Django project. The decision to have a unique constraint was taken after test data was already created in the table.

Now while running migrations, I came across the following error:

django.db.utils.IntegrityError: UNIQUE constraint failed: movt_frt.frt_group_id, movt_frt.rec_loc_id, movt_frt.dis_loc_id

I have tried creating similar unique constraints on table that previously held no data and migrations happened successfully.

My question is:

  1. Am I right in concluding that the Migration is failing because the table already has data residing in it?

  2. Is there a way to do some changes to the migration file on the lines as discussed here and attempt migration again, to run successfully?

I am using Django ver. 2.0.6

1 Answers1

1

I don't know if this question is still relevant. It's not so much that the table is filled with data. These data already contains combinations that conflict with your specified 'unique_together'. Overruling is not possible, but if the table is not too big you could correct it manually.

Kurt
  • 11
  • 1