skip to Main Content

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (Connection: mysql, SQL: alter table personal_a ccess_tokens add index personal_access_tokens_tokenable_type_tokenable_id_index(`tokenable_

I tried to add index with the specified key length

$table->index(['tokenable_type', 'tokenable_id'], 'tokenable_index');

but still encountering the error

2

Answers


  1. You can try shorten column name like this

    $table->index(['type', 'tokenable_id'], 'tokenable_index');
    
    
    Login or Signup to reply.
  2. $table->index([‘type’, ‘tokenable_id’], ‘tokenable_index’);

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search