sometimes when we run php artisan migrate we got Laravel Migration Problem : Syntax error or access violation, 1071 specified key was too long; max key length is 1000 bytes. For solution let’s follow the below steps.
Solutions Steps:
- Go to YourProjectFolder/app/providers/AppServiceProvider.php directory
- Add following line before Class
1use Illuminate\Support\Facades\Schema;
123456789<?phpnamespace App\Providers;use Illuminate\Support\ServiceProvider;<strong>use Illuminate\Support\Facades\Schema;</strong>class AppServiceProvider extends ServiceProvider{ - Add this line inside boot function
1Schema::defaultStringLength(191);
I mean like following
1234public function boot(){<strong>Schema::defaultStringLength(191);</strong>} - lets go to our database and delete all the tables manually.
- then again run below line on the terminal.
1php artisan migrate