Illuminate\Database\QueryException SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (Connection: mysql, SQL: alter table `roles` add unique `roles_role_name_unique`(`role_name`)) in Laravel 11
SOLUTION: When Above error is occurred at that time we have to specify length in column name. If we specify only column name in migration file the above error is occurred. For Example, if we specify only varchar instead of varchar(50) then above error is occurred. So To solve above Error, we have to specify column length as shown below image. In below image, we have specified $table->string("role_name",50)->unique();