Home > PHP Framework > Laravel > body text

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

藏色散人
Release: 2021-11-29 14:54:35
forward
1785 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:
source:learnku.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template