vinoth kumar
vinoth kumar

Reputation: 507

Syntax error or access violation: 1059 Identifier name is too long

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?

Upvotes: 39

Views: 64732

Answers (4)

Sina Ghoshuni
Sina Ghoshuni

Reputation: 147

According to mysql table name character count limit is 64 character, but your character length is 66 and reach to limitation.

I recive this error and solved with the name method like this:

$table->foreignId('my_foreign_id')->constrained()->on('my_foreign_table')->name('my_foreign_name');

Upvotes: 1

Muzammil Hussain
Muzammil Hussain

Reputation: 221

Provide your own short name to key.

$table->unique(['product_id', 'company_id', 'price', 'delivery_hours'], 'prices_history_index_unique');

Upvotes: 20

DeviOus
DeviOus

Reputation: 21

Just give the primary key a shorter name.

Like this:

$table->primary(['company_store_id', 'company_product_id'], 'product_store_id');

Upvotes: 1

Michael
Michael

Reputation: 10474

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.

Upvotes: 46

Related Questions