Home > PHP Framework > Laravel > What should I do if an error occurs in the Larabel migration file?

What should I do if an error occurs in the Larabel migration file?

藏色散人
Release: 2021-11-29 14:54:35
forward
1866 people have browsed it

The tutorial column of Laravel below will introduce to you the solution to the SQLSTATE[42000] error when migrating files in Larabel. I hope it will be helpful to everyone!

What should I do if an error occurs in the Larabel migration file?

The solution to an error reported when Laravel executes the php artisan migrate command

Illuminate\Database\QueryException  : 
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; 
max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
Copy after login

Solution

Modify app/ Add the following content to the Providers/AppServiceProvider.php file:

<?php

namespace App\Providers;use Illuminate\Support\ServiceProvider;use Illuminate\Support\Facades\Schema;class AppServiceProvider extends ServiceProvider{
    public function register()
    {
    }

    public function boot()
    {
        Schema::defaultStringLength(191);
    }}
Copy after login

Modify part

Schema::defaultStringLength(191);
Copy after login
Related recommendations: The latest five Laravel video tutorials

The above is the detailed content of What should I do if an error occurs in the Larabel migration file?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Composer cannot install laravel
From 1970-01-01 08:00:00
0
0
0
Laravel Space/laravel-backup cannot be installed
From 1970-01-01 08:00:00
0
0
0
Laravel 5.1 Login laravel comes with it No more
From 1970-01-01 08:00:00
0
0
0
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template