35

I receive a MySQL error when I create a table:

SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'FK_SALES_FLAT_CREDITMEMO_GRID_ARCHIVE_STORE_ID_CORE_STORE_STORE_ID' is too long

How can the default Identifier name size be increased or how can I solve this otherwise?

Michael
  • 10,124
  • 1
  • 34
  • 49
vinoth kumar
  • 467
  • 1
  • 4
  • 6

3 Answers3

43

Please take a look at http://dev.mysql.com/doc/refman/5.5/en/identifiers.html - you are limited to 64 chars to an identifier.

Michael
  • 10,124
  • 1
  • 34
  • 49
18

Provide your own shot name to key.

$table->unique(['product_id', 'company_id', 'price', 'delivery_hours'], 'prices_history_index_unique');
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
  • For context, this answer explains how you can fix this issue with **Laravel**, when it automatically creates unique keys that are too long. In your migration you can ad the line above – Kerwin Sneijders Mar 30 '23 at 14:47
0

Just give the primary key a shorter name.

Like this:

$table->primary(['company_store_id', 'company_product_id'], 'product_store_id');
DeviOus
  • 11
  • 2