jeudi 25 janvier 2018

Laravel - Integrity Constraint Violation (Duplicate Entry for Key)

I have a table that I have recently edited to add another index using two columns (which combined are required to be unique).

The problem is now I get an error when I go to create a new model record: Integrity constraint violation: 1062 Duplicate entry ... for key ....

The two columns are titled:

  • shipment_origin
  • pro_number

So as an example, the end result would look like: 1-230185

And I have checked, the record is created technically, it just doesn't follow through and the error is returned. So to make it simple, there is no record before hand (so there's no duplicate entry), a record is created in the database and the error is returned (no matter what).

Or is there a way to go about doing this directly through laravel rather than MySQL?

Thanks - Matt



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire