Answered by : handsome-hawk-ca4g4lhp3n0u
use Illuminate\Support\Facades\Schema;
public function boot()
{ Schema::defaultStringLength(191);
}
Source : https://laravel-news.com/laravel-5-4-key-too-long-error | Last Update : Wed, 06 May 20
Answered by : hamza-bin-sajid
use Illuminate\Support\Facades\Schema;
/** * Bootstrap any application services. * * @return void */
public function boot()
{ Schema::defaultStringLength(191);
}
Source : https://stackoverflow.com/questions/42244541/laravel-migration-error-syntax-error-or-access-violation-1071-specified-key-wa | Last Update : Mon, 23 Nov 20
Answered by : christian-racuya
// /app/Providers/AppserviceProvider.php
use Illuminate\Support\Facades\Schema;
public function boot()
{ Schema::defaultStringLength(191);
}
Source : | Last Update : Tue, 09 Aug 22
Answered by : jaskaran-singh
Path : App/Providers/AppServiceProvider
Schema::defaultStringLength(191);
in AppServiceProvider didn't work for me. What worked for was editing the database.php file in config folder. Just edit
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
to
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
and it should work, although you will be unable to store extended multibyte characters like emoji.
Source : | Last Update : Mon, 23 Aug 21
Answered by : shafeeque-ahmad
Inside config/database.php, replace this line for mysql
Copy Code
'engine' => null',
with
Copy Code
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
Instead of setting a limit on your string lenght.
Source : https://laracasts.com/discuss/channels/general-discussion/syntax-error-or-access-violation-1071-specified-key-was-too-long | Last Update : Sat, 06 Aug 22
Answered by : shafeeque-ahmad
use Illuminate\Support\Facades\Schema;
/** * Bootstrap any application services. * * @return void */
public function boot()
{ Schema::defaultStringLength(191);
}
Source : https://stackoverflow.com/questions/42244541/laravel-migration-error-syntax-error-or-access-violation-1071-specified-key-wa | Last Update : Mon, 31 Jan 22
Answered by : viruscom1000
// Solution 1
// In App/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Schema;
public function boot()
{ Schema::defaultStringLength(191);
}
// Solution 2
// In config/database.php
// For 'mysql' change
'mysql' => [ // 'engine' => null, 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', ],
Source : | Last Update : Sun, 18 Sep 22
Answered by : shafeeque-ahmad
According to the official Laravel 7.x documentation, you can solve this quite easily.
Update your /app/Providers/AppServiceProvider.php to contain:
use Illuminate\Support\Facades\Schema;
/** * Bootstrap any application services. * * @return void */
public function boot()
{ Schema::defaultStringLength(191);
Source : https://stackoverflow.com/questions/42244541/laravel-migration-error-syntax-error-or-access-violation-1071-specified-key-wa | Last Update : Thu, 28 Jul 22
Answered by : hadi
$table->string('name',64);
$table->string('email',128)->unique();
Source : https://stackoverflow.com/questions/42244541/laravel-migration-error-syntax-error-or-access-violation-1071-specified-key-wa | Last Update : Wed, 30 Nov 22