vendredi 3 août 2018

When doing multiple unique columns can I give a custom name in laravel 5.6?

Consider the following example:

$table->unique(['site_id', 'inventory_items', 'lsd_location_id']);

This then throws the error:

SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'lsd_location_units_site_id_inventory_items_lsd_location_id_unique' is too long (SQL: alter table lsd_location_units add unique lsd_location_units_site_id_inventory_items_lsd_location_id_unique(site_id, inventory_items, lsd_location_id))

So the question is: Can I give this a different name and still hold the unique key as it is, so instead of its long name maybe: sid_ii_lsd_location_unuiqe or something similar?

A) Is that allowed in MYSQL?

B) Any way around this issue? As I need all three of these.

The goal is to say only one inventory_item_id per LSD Location ID Per site.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire