You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you try to make many columns as unique key, laravel is writing each column name after each other and is not cutting them after the max length.
For example, first_name, last_name, phone and company_name:
You will get following error message by running the migrate command.
[Exception]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table customers add unique customers_first_name_last_name_company_name_phone_unique(first_name, last_name, company_name, phone))
The text was updated successfully, but these errors were encountered:
Just in case someone stumbles across this: The problem isn't the length of the name of the index but the combined field length of the columns that are indexed.
Solution is to restrict the length of the individual columns, e.g. specify a max length for first_name, last_name etc. in the example above, i.e. $table->string('first_name', 50);
I see the same question with use the laravel5.4 and now it's sloved, the first thing make sure you can see the welcome.blade.php,and then ,change the app\AppServiceProvider.php,
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
If you try to make many columns as unique key, laravel is writing each column name after each other and is not cutting them after the max length.
For example, first_name, last_name, phone and company_name:
You will get following error message by running the migrate command.
[Exception]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table
customers
add unique customers_first_name_last_name_company_name_phone_unique(first_name
,last_name
,company_name
,phone
))The text was updated successfully, but these errors were encountered: