Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Neewd's avatar
Level 1

Installation error when migrating

I just got Spark, and after I tried to migrate the tables, I got the following error :

Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table announcements add primary key announcements_id_primary(id))

In the older version of Laravel I was used to correct that by adding a line in the boot() of the AppServiceProvider.

Schema::defaultStringLength(191);

But the line was already there so I don't know where the problem. I didn't touch to any file so ...

If anyone had this issue I'll be glad to hear the solution !

Thanks

0 likes
1 reply
bobbybouwmann's avatar

For some context you can read this: https://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes#answer-1814594

So basically you have two options here. Either make the field length of some field differently or upgrade your mysql/mariadb to a newer version that does support this!

Source: https://stackoverflow.com/questions/23786359/laravel-migration-unique-key-is-too-long-even-if-specified?noredirect=1&lq=1

Please or to participate in this conversation.